From: Martin Marques <martin@bugs.unl.edu.ar>
To: Bruno Wolff III <bruno@wolff.to>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: Robert Creager <Robert_Creager@LogicalChaos.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: inverse of "day of year"
Date: Mon, 22 Mar 2004 10:14:40 -0300
Message-ID: <200403221014.40555.martin@bugs.unl.edu.ar> (raw)
In-Reply-To: <20040322125054.GA1135@wolff.to>
References: <200403190906.17641.martin@bugs.unl.edu.ar>
<200403220832.32968.martin@bugs.unl.edu.ar>
<20040322125054.GA1135@wolff.to>
El Lun 22 Mar 2004 09:50, escribió:
>
> 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.
Any thoughts on how this could affect date manipulation?
mydb=> select '29/2/2004'::date + ((2005 - date_part('year', now())::int) ||
'years')::interval;
?column?
---------------------
2005-02-28 00:00:00
AFAIKS with other dates this works OK. :-)
--
10:11:02 up 13 days, 14:42, 4 users, load average: 0.17, 0.12, 0.16
-----------------------------------------------------------------
Martín Marqués | select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica | DBA, Programador, Administrador
Universidad Nacional
del Litoral
-----------------------------------------------------------------
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: martin@bugs.unl.edu.ar, bruno@wolff.to, tgl@sss.pgh.pa.us, Robert_Creager@LogicalChaos.org
Subject: Re: inverse of "day of year"
In-Reply-To: <200403221014.40555.martin@bugs.unl.edu.ar>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox