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!

TO_DATE(TO_CHAR) - YYYY and YYYYMM formats

823570Dec 13 2010 — edited Dec 13 2010
Hi,

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
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jan 10 2011
Added on Dec 13 2010
2 comments
4,896 views