Help find the Last run date from previous month
853050Apr 5 2011 — edited Apr 5 2011Hi 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