From: | Alvaro Herrera <alvherre(at)commandprompt(dot)com> |
---|---|
To: | Dhugael McLean <box(at)yourtechonline(dot)com> |
Cc: | pgsql-bugs(at)postgresql(dot)org |
Subject: | Re: BUG #3260: Subtracting intervals |
Date: | 2007-05-03 17:15:46 |
Message-ID: | 20070503171546.GH4218@alvh.no-ip.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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.
From | Date | Subject | |
---|---|---|---|
Next Message | Jose Blanco | 2007-05-03 20:12:26 | order by question. |
Previous Message | Tom Lane | 2007-05-03 17:06:23 | Re: BUG #3260: Subtracting intervals |