Re: interval output format available that removes ambiguity ?

Поиск
Список
Период
Сортировка
От Bruno Wolff III
Тема Re: interval output format available that removes ambiguity ?
Дата
Msg-id 20040504174241.GA11199@wolff.to
обсуждение исходный текст
Ответ на interval output format available that removes ambiguity ?  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Ответы Re: interval output format available that removes ambiguity ?  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Список pgsql-general
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.

В списке pgsql-general по дате отправления:

Предыдущее
От: David Wheeler
Дата:
Сообщение: ANNOUNCE: Bricolage 1.8.0 Arrives!
Следующее
От: Manfred Koizar
Дата:
Сообщение: Re: 7.4.2 Regression tests: test stats loops indefinately...