This content has been marked as final. Show 5 replies
sysdate is date datatype...so before converting a date format you need to convert string->date and then date-> required string format.1 person found this helpful
select to_char(to_date('01-Dec-09','dd-mon-yy'),'MON') from dual;
Hi1 person found this helpful
'01-Dec-09' is a string not a date.
would be the equivalent of
select to_char('01-Dec-09','MONTH') from dual;
What exactly is it that you are trying to do?
SELECT 'DECEMBER' FROM DUAL.
You would have to pass an actual date, not a string. So you could do something like1 person found this helpful
SELECT to_char( to_date( '01-Dec-2009', 'DD-Mon-YYYY' ), 'MONTH' ) FROM dual
SELECT to_char( date '2009-12-01', 'MONTH ) FROM dual
Thanks guys! I got it now.
Hi,1 person found this helpful
You need to turn your STRING into a DATE first using TO_DATE and the correct format, and apply TO_CHAR after that, using the desired format:
SQL> select to_char(to_date('01-Dec-09','dd-Mon-rr'),'Mon') from dual; TO_ --- Dec 1 row selected. SQL> select to_char(to_date('01-Dec-09','dd-Mon-rr'),'mm') from dual; TO -- 12 1 row selected.