Re: Q: Default month in TO_DATE
Date: Sun, 11 Jan 2009 00:44:00 +0100
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.
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
Maxim Received on Sat Jan 10 2009 - 17:44:00 CST