TO_DATE(TO_CHAR) - YYYY and YYYYMM formats
823570Dec 13 2010 — edited Dec 13 2010Hi,
I have a table with the following data -
Table: Date_example
Data :
8/25/2010
9/2/2010
9/24/2010
10/19/2010
12/6/2010
12/9/2010
The following query returns -
1.) select TO_DATE(to_char(day, 'YYYYMM'),'YYYYMM') day from date_example;
DAY
8/1/2010
9/1/2010
9/1/2010
10/1/2010
12/1/2010
12/1/2010
I am confused as to how the Date part is being displayed even though the format string has ONLY YYYYMM
SImilarly -
2.) select TO_DATE(to_char(day, 'YYYY'),'YYYY') from date_example;
DAY
12/1/2010
12/1/2010
12/1/2010
12/1/2010
12/1/2010
12/1/2010
Here, it is even more confusing.
Could anyone please explain this behaviour?
Thanks in advance
Regards,
Anand