Re: BUG #1993: Adding/subtracting negative time intervals

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)au>
Cc: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>, Michael Fuhr <mike(at)fuhr(dot)org>, Michael Glaesemann <grzm(at)myrealbox(dot)com>, Russell Smith <mr-russ(at)pws(dot)com(dot)au>, pgsql-bugs(at)postgresql(dot)org, Nicholas <hb(at)x256(dot)com>
Subject: Re: BUG #1993: Adding/subtracting negative time intervals
Date: 2005-10-26 04:38:06
Message-ID: 1827.1130301486@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs pgsql-hackers

Klint Gore <kg(at)kgb(dot)une(dot)edu(dot)au> writes:
> On Tue, 25 Oct 2005 23:41:54 -0400 (EDT), Bruce Momjian
> <pgman(at)candle(dot)pha(dot)pa(dot)us> wrote:
>> test=> select
>> test-> ('2005-10-30 13:22:00-05'::timestamptz -
>> test(> '2005-10-29 13:22:00-04'::timestamptz);
>> ?column?
>> ----------
>> 25:00:00
>> (1 row)

> Is that actually the correct answer?

I'm of the opinion that the correct answer, or at least the usually
desired answer, is "1 day".

> Disregarding daylight savings, there is 25hrs between them. Once
> daylight savings is taken into account there should be 24 or 26 hours
> between them (southern/northern hemisphere respectively).

If you want the numeric "25 hours" answer, you can always extract(epoch)
from both of them and subtract. There isn't any way to get a symbolic
"1 day" answer unless we make timestamp subtraction provide it.

regards, tom lane

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Tom Lane 2005-10-26 04:44:50 Re: BUG #1993: Adding/subtracting negative time intervals
Previous Message John R Pierce 2005-10-26 04:35:44 Re: BUG #1993: Adding/subtracting negative time intervals

Browse pgsql-hackers by date

  From Date Subject
Next Message Christopher Kings-Lynne 2005-10-26 04:44:10 Re: Sequence dependencies
Previous Message John R Pierce 2005-10-26 04:35:44 Re: BUG #1993: Adding/subtracting negative time intervals