Search Postgresql Archives

Re: interval output format available that removes ambiguity ?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, May 04, 2004 at 12:24:37 +0200,
  Karsten Hilbert <Karsten.Hilbert@gmx.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.

---------------------------(end of broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux