Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: select to_date('2004','YYYY') NOT Jan 1 2004 - Here's why

Re: select to_date('2004','YYYY') NOT Jan 1 2004 - Here's why

From: Jarson <jarsonk_at_nospam.com>
Date: Wed, 24 Mar 2004 13:42:23 -0500
Message-ID: <kFk8c.18933$A_2.999157@news20.bellglobal.com>


That's it! Thanks!

"Turkbear" <john.g_at_dot.spamfree.com> wrote in message news:fhj360hg5nrf6u5814hlu0hd1i05g3fcmb_at_4ax.com...
>
> OK, I found out ( should have paid more attention in class, many years
ago)
>
> Oracle 'knows' what dates should look like ( depending on your
NLS_DATE_FORMAT) so, when you request a to_date conversion,
> Oracle will substitute default values for any part of the date you do not
specify in the format string:
> If no Month, the Current month is used.
> If no Day, the First day of the Month is used( because all months have a
first)
> If no Year, the Current year
> Time is Midnight, if not provided.
>
>
>
>
>
>
>
>
> Turkbear <john.g_at_dot.spamfree.com> wrote:
>
> >"Jim Kennedy" <kennedy-downwithspammersfamily_at_attbi.net> wrote:
> >
> >>
> >>"Jarson" <jarsonk_at_nospam.com> wrote in message
> >>news:pdi8c.18858$A_2.978850_at_news20.bellglobal.com...
> >>> When I run the following SQL
> >>>
> >>> SQL> select to_date('2004','YYYY') from dual ;
> >>>
> >>> The result is 01-Mar-04. I was expecting 01-Jan-04.
> >>> Is it returning March because that is the current month, or does it
always
> >>> return March? Does anyone else get this (I'm on Oracle 8.1.6)?
> >>>
> >>> Jarson
> >>>
> >>>
> >>Why? You have only specified the year and not the month and the day.
If
> >>you want 1/1/2004 then specify that.
> >>Jim
> >>
> >
> >That does not explain the 'assumption' Oracle is making, that you want
the 1st day of the current month for the year
> >indicated...Why does it even query SYSDATE???
> >
>
Received on Wed Mar 24 2004 - 12:42:23 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US