Robert Creager <[EMAIL PROTECTED]> writes:
> Martin Marques <[EMAIL PROTECTED]> confessed:
>> Is there a function that would give me the date for a given day of year?

> Something like:

> select date_trunc( 'year', now() ) + (extract( doy from now() ) - 1) *
> '1day'::interval;

timestamp + interval arithmetic is likely to give you problems at
daylight savings boundaries, since '1day' will be taken as '24hours'.
A more reliable way to get (what I assume is) the desired result is
to use the date + integer operator:

select date_trunc('year', now())::date + (extract(doy from now()) - 1)::integer;

                        regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
    (send "unregister YourEmailAddressHere" to [EMAIL PROTECTED])

Reply via email to