Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Help find the Last run date from previous month

853050Apr 5 2011 — edited Apr 5 2011
Hi all

I am stuck trying to find the Last Run Date from the previous month.

select distinct(date_ran) from TABLE X where date_ran like '%/11-%' order by date_ran desc gives

"03/30/11-06:19
"
"03/25/11-03:01
"
"03/24/11-03:00
"
"03/23/11-03:00
"
"03/22/11-03:00
"
"03/21/11-03:00
"
"03/18/11-03:00
"
"03/17/11-00:00
"
"03/16/11-06:31
"
"02/15/11-07:42
"
"02/15/11-06:00
"
"02/14/11-08:19
"
Here the result I am trying to acheive is 02/15/11-07:42 ;Note the column date_ran is a VARCHAR2(255) and not a TIMESTAMP

I tried
select ADD_MONTHS(to_date(max(date_ran), 'MM/DD/YYYY-HH24:MI'),-1)
from daily_tests_a
where date_ran like '%/11-%'
order by date_ran desc

which returns 2/28/0011 6:19:00 AM and that is not the result I am looking for

Regards
SMK
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on May 3 2011
Added on Apr 5 2011
5 comments
426 views