dbTalk Databases Forums  

Q: Default month in TO_DATE

comp.databases.oracle.misc comp.databases.oracle.misc


Discuss Q: Default month in TO_DATE in the comp.databases.oracle.misc forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Malcolm Dew-Jones
 
Posts: n/a

Default Q: Default month in TO_DATE - 01-09-2009 , 04:47 PM






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.


Reply With Quote
  #2  
Old   
Maxim Demenko
 
Posts: n/a

Default Re: Q: Default month in TO_DATE - 01-10-2009 , 05:44 PM






Malcolm Dew-Jones schrieb:
Quote:
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/B....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


Reply With Quote
  #3  
Old   
Malcolm Dew-Jones
 
Posts: n/a

Default Re: Q: Default month in TO_DATE - 01-10-2009 , 07:54 PM




On Sun, 11 Jan 2009, Maxim Demenko wrote:

Quote:
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/B....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

Thanks,

I didn't think to look at the _data type_ documentation, I was looking at
the conversion functions (TO_DATE from char).



Reply With Quote
  #4  
Old   
Michel Cadot
 
Posts: n/a

Default Re: Default month in TO_DATE - 03-03-2009 , 01:08 PM




"Malcolm Dew-Jones" <yf110 (AT) vtn1 (DOT) victoria.tc.ca> a écrit dans le message de news: 4967e206$1 (AT) news (DOT) victoria.tc.ca...
Quote:
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.

SQL> select to_date('2009','YYYY') from dual;
TO_DATE('2009','YYY
-------------------
01/03/2009 00:00:00

1 row selected.

Regards
Michel




Reply With Quote
  #5  
Old   
CarlosAL
 
Posts: n/a

Default Re: Default month in TO_DATE - 03-05-2009 , 02:24 AM



On 3 mar, 20:08, "Michel Cadot" <micadot{at}altern{dot}org> wrote:
Quote:
"Malcolm Dew-Jones" <yf... (AT) vtn1 (DOT) victoria.tc.ca> a écrit dans le messagede news: 4967e20... (AT) news (DOT) victoria.tc.ca...
|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.
|

SQL> select to_date('2009','YYYY') from dual;
TO_DATE('2009','YYY
-------------------
01/03/2009 00:00:00

1 row selected.

Regards
Michel
Hi all.

The default year, month and day is a little convoluted...

I wrote about it a while ago. You may take a look here:

http://carlosal.wordpress.com/2007/0...o-con-to_date/

It's written in spanish, but SQL is SQL is SQL ;-)

HTH.

Cheers.

Carlos.


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.