Skip site navigation (1) Skip section navigation (2)

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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: andrew(at)supernews(dot)com
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: BUG #1993: Adding/subtracting negative time intervals
Date: 2005-10-26 14:19:09
Message-ID: 5765.1130336349@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-bugspgsql-hackers
Andrew - Supernews <andrew+nonews(at)supernews(dot)com> writes:
> Um, what? Under what conditions is it permissable for simple arithmetic on
> (only) timestamptz values (which may have originated in different timezones
> neither of which is the current one) to be dependent on the current timezone
> setting?

Timestamp subtraction will give different answers depending on whether
there's a DST adjustment in between.

regression=# select '2005-10-31'::timestamptz - '2005-10-28'::timestamptz;
    ?column?
-----------------
 3 days 01:00:00
(1 row)

regression=# set timezone = 'Japan';
SET
regression=# select '2005-10-31'::timestamptz - '2005-10-28'::timestamptz;
 ?column?
----------
 3 days
(1 row)

BTW, if we were doing subtraction symbolically as I think we should,
these *would* give the same answer, ie, '3 days' in both cases.  Care to
rethink your opposition to that idea?

			regards, tom lane

In response to

Responses

pgsql-hackers by date

Next:From: Michael PaesoldDate: 2005-10-26 14:48:05
Subject: Re: expanded \df+ display broken in beta4
Previous:From: Tom LaneDate: 2005-10-26 14:13:36
Subject: Re: BUG #1993: Adding/subtracting negative time intervals

pgsql-bugs by date

Next:From: Kevin GrittnerDate: 2005-10-26 14:20:49
Subject: Re: BUG #1993: Adding/subtracting negative time
Previous:From: Tom LaneDate: 2005-10-26 14:13:36
Subject: Re: BUG #1993: Adding/subtracting negative time intervals

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group