This content has been marked as final. Show 4 replies
1 person found this helpful
CONVERT and double quotes looks like MS SQL Server to me
SELECT TO_DATE('19 Nov 2012','dd Mon yyyy') FROM dual; SELECT TO_CHAR(TO_DATE('19 Nov 2012','dd Mon yyyy') ,'YYYYMMDD') FROM dual;
It appears that your research lead you to a SQL Server thread. SQL Server uses arbitrary numbers to represent date formats. Oracle does not-- the number 112 has no relevance to Oracle.
In Oracle, you convert a date to a string using the TO_CHAR function
Of course, that assumes that you are starting with a date (as I do with my date literal). If you are starting with a string that represents a date and you want to convert it to a string that represents that same date in a different format, you would need to use both a TO_DATE and a TO_CHAR to convert the original string to a date and the date to a different string
SELECT to_char( date '2012-11-19', 'YYYYMMDD' ) FROM dual
SELECT to_char( to_date( '19 Nov 2012', 'DD Mon YYYY' ), 'YYYYMMDD' ) FROM dual
Hi,1 person found this helpful
Note the mon in stewad of mmm in the date format string
select '19 Nov 2012' txt_1 ,to_char(TO_DATE('19 Nov 2012','dd mon yyyy'),'YYYYMMDD') txt_2 FROM DUAL; TXT_1 TXT_2 ----------- -------- 19 Nov 2012 20121119
Thanks all, specially Justin, thanks for providing such a clear explenation.