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

Re: select to_date('2004','YYYY') NOT Jan 1 2004

From: Jarson <jarsonk_at_nospam.com>
Date: Wed, 24 Mar 2004 13:40:10 -0500
Message-ID: <iDk8c.18932$A_2.998755@news20.bellglobal.com>


You shouldn't have to (albeit this is the point of the argument and very easy to work around). I didn't specify the day of the month, hour, minute or second either as these default to each value's start, as expected.

I expected that if you tell the to_date function to convert just the year, it would interpret as the "start of the year". If instead as it uses the current month as a default, then I would expect it to also use the current day, hour, minute and second; but it does not.

        sql> select to_char(to_date('2004', 'YYYY'), 'DD-MON-YYYY HH:MI:SS') from dual

        returns 01-MAR-2004 12:00:00

Jarson

"Jim Kennedy" <kennedy-downwithspammersfamily_at_attbi.net> wrote in message news:2xi8c.82903$Cb.1101266_at_attbi_s51...
>
> "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
>
>
Received on Wed Mar 24 2004 - 12:40:10 CST

Original text of this message

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