Re: BUG #3260: Subtracting intervals

Поиск
Список
Период
Сортировка
От Alvaro Herrera
Тема Re: BUG #3260: Subtracting intervals
Дата
Msg-id 20070503171546.GH4218@alvh.no-ip.org
обсуждение исходный текст
Ответ на BUG #3260: Subtracting intervals  ("Dhugael McLean" <box@yourtechonline.com>)
Список pgsql-bugs
Dhugael McLean wrote:

> select '1 day'::interval - '55 minutes'::interval;
>
>     ?column?
> -----------------
>  1 day -00:55:00
>
> If the interval periods are both minutes (hours - hours, days - days, etc),
> this works fine. Days - minutes seems to fail. This should output 23:05:00.

No, that answer would be wrong because not all days are 24 hours long
(think DST).  You can use justify_hours() if you want to make that
assumption:

alvherre=# select justify_hours('1 day'::interval - '55 minutes'::interval);
 justify_hours
---------------
 23:05:00
(1 fila)

--
Alvaro Herrera                                http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: BUG #3260: Subtracting intervals
Следующее
От: "Jose Blanco"
Дата:
Сообщение: order by question.