Skip site navigation (1) Skip section navigation (2)

Re: inverse of "day of year"

From: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>,Robert Creager <Robert_Creager(at)LogicalChaos(dot)org>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: inverse of "day of year"
Date: 2004-03-22 11:32:32
Message-ID: 200403220832.32968.martin@bugs.unl.edu.ar (view raw or flat)
Thread:
Lists: pgsql-sql
El Vie 19 Mar 2004 12:10, Tom Lane escribió:
> Robert Creager <Robert_Creager(at)LogicalChaos(dot)org> writes:
> > Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> 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'.

Is there information on how other intervals are taken? I mean, how is '1 year' 
afected with the leap years?

-- 
 08:30:01 up 13 days, 13:01,  3 users,  load average: 2.04, 1.80, 1.04
-----------------------------------------------------------------
Martín Marqués        | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador
             Universidad Nacional
                  del Litoral
-----------------------------------------------------------------


In response to

Responses

pgsql-sql by date

Next:From: Achilleus MantziosDate: 2004-03-22 11:40:11
Subject: Re: special integrity constraints
Previous:From: Bruno Wolff IIIDate: 2004-03-22 11:26:04
Subject: Re: special integrity constraints

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group