Re: inverse of "day of year"

From: Bruno Wolff III <bruno(at)wolff(dot)to>
To: Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar>
Cc: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, Robert Creager <Robert_Creager(at)LogicalChaos(dot)org>, pgsql-sql(at)postgresql(dot)org
Subject: Re: inverse of "day of year"
Date: 2004-03-22 12:50:54
Message-ID: 20040322125054.GA1135@wolff.to
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

On Mon, Mar 22, 2004 at 08:32:32 -0300,
Martin Marques <martin(at)bugs(dot)unl(dot)edu(dot)ar> wrote:
>
> Is there information on how other intervals are taken? I mean, how is '1 year'
> afected with the leap years?

Intervals are stored as two components. One is absolute time difference,
and the other is in months. '1 year' is equivalent to '12 months'.
The documentation on how they work in corner cases (when added or subtracted
from timestamp(tz)) is sparse. It isn't documented whether the part in months
or the absolute time is added first or what timezone is used (for
timestamptz) when adding the months part.
The basic idea is that months are added by looking at the timestamp
as date and time and adding the appropiate number of months to the date
and then converting back to a timestamp. It isn't documented what happens
when the day of the month is past the end of the new month, but it looks
like the last day of new month is used.
If you convert an interval to an absolute time (such as by extracting the
epoch), then months are converted to 30 days. Again, I don't think this
is documented.

In response to

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Erik Thiele 2004-03-22 13:10:42 Re: special integrity constraints
Previous Message Achilleus Mantzios 2004-03-22 11:40:11 Re: special integrity constraints