Re: interval output format available that removes ambiguity ?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: interval output format available that removes ambiguity ?
Дата
Msg-id 25609.1083766237@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Re: 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
Karsten Hilbert <Karsten.Hilbert@gmx.net> writes:
> I am now looking for a way to say:
>  select age('1999-2-2', '1999-3-2', without months);
>  select age('1999-5-2', '1999-6-2', without months);
> and get "28 days" in the first and "31 days" in the second
> result.

Just subtract the two timestamps (or dates) instead of using age().
Then you get an interval that has no month component.

> However, if you say that "1 mon" is always considered 30 days

He didn't say that.  He said that when the system *must* convert a
month-based interval to days and it has no date reference for it,
it uses 30 days.  Something like "now() + '1 month'::interval"
will do the "right thing".  This IMHO is the main application of
intervals with month components ...

            regards, tom lane

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

Предыдущее
От: Lonni Friedman
Дата:
Сообщение: vacuumdb is failing with NUMBER OF INDEX TUPLES NOT THE SAME AS HEAP
Следующее
От: Robert Treat
Дата:
Сообщение: Re: FYI, foxpro to postgresql conversion scripts