From: | Bruno Wolff III <bruno(at)wolff(dot)to> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: interval output format available that removes ambiguity ? |
Date: | 2004-05-04 17:42:41 |
Message-ID: | 20040504174241.GA11199@wolff.to |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Tue, May 04, 2004 at 12:24:37 +0200,
Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net> wrote:
> I have the need to output intervals (ages in this case).
> PostgreSQL takes great care to handle months correctly (eg
> take into account varying months lengths). This is only
> possible if either end point or start point of an interval are
> known. For post processing some of the ambiguity of what
> "2 mons" means would be removed if "61 days" was returned.
This is sort of done now, but the months part of the interval will be
treated as 30 days.
> Is there a way to tell PostgreSQL to return that type of
> interval (eg use weeks, days, hours, minutes, seconds, ...
> but not months and perhaps not even years [leap years, etc]) ?
> to_char(interval, text) doesn't work as it is applied after
> the fact.
You can extract "epoch" from the interval to get the total number of
seconds in the interval (converting months to the number of seconds
in 30 days) and then divide that by the appropiate amount.
From | Date | Subject | |
---|---|---|---|
Next Message | Karl O. Pinc | 2004-05-04 17:52:58 | FYI, foxpro to postgresql conversion scripts |
Previous Message | Manfred Koizar | 2004-05-04 17:42:02 | Re: 7.4.2 Regression tests: test stats loops indefinately... |