Re: Q: Default month in TO_DATE

From: Maxim Demenko <mdemenko_at_gmail.com>
Date: Sun, 11 Jan 2009 00:44:00 +0100
Message-ID: <496932C0.8010302_at_gmail.com>



Malcolm Dew-Jones schrieb:
> I don't see this in the TO_DATE documentation, and because it's January I
> can't see how to test this to confirm.
>
> select to_date('2009','YYYY') from dual;
> => shows 01-JAN-2009
>
> The day is defaulting to 1, but what of the month?
>
> - is the unspecified month defaulting to 1 (i.e. January)
>
> - or is the unspecified month defaulting to the current month (which just
> happens to be January because of when I ran the test).
>
>
> Thanks for any feedback.
>

 From
http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14261/datatypes.htm#sthref795

DATE Datatype

You use the DATE datatype to store fixed-length datetimes, which include the time of day in seconds since midnight. The date portion defaults to the first day of the current month; the time portion defaults to midnight. The date function SYSDATE returns the current date and time.

So, if you query the same in february, you'll get 01-FEB-2009

Best regards

Maxim Received on Sat Jan 10 2009 - 17:44:00 CST

Original text of this message