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: Charlie Edwards <charlie3101_at_hotmail.com>
Date: 25 Mar 2004 03:50:32 -0800
Message-ID: <217ac5a8.0403250350.78d79d4f@posting.google.com>


Sybrand Bakker <sybrandb_at_hccnet.nl> wrote in message news:<ks446052j4gh68u3na9tev5r6v1klnsg5r_at_4ax.com>...
> On Wed, 24 Mar 2004 13:40:10 -0500, "Jarson" <jarsonk_at_nospam.com>
> wrote:
>
> >You shouldn't have to
> ignorance is bliss. Any element you don't specify in to_char defaults
> to the sysdate, as documented.
> You should have TRUNCed the date to YYYY

Well, possibly it is documented, but it certainly isn't the case that "Any element you don't specify in to_char defaults to the sysdate" otherwise

TO_DATE('2004','YYYY') would equal SYSDATE, wouldn't it?

I don't think the OP was actually looking to get the first day of the year, just posting the fact that (if this year is 2004)

TO_DATE('2004','YYYY') = TRUNC(SYSDATE,'MONTH') rather than
TRUNC(SYSDATE,'YEAR') or even TRUNC(SYSDATE)

Not a problem in any way, but (documented or not) slightly curious behaviour.

CE Received on Thu Mar 25 2004 - 05:50:32 CST

Original text of this message

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