Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: select to_date('2004','YYYY') NOT Jan 1 2004
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
![]() |
![]() |