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

Re: Inconsistant DOW...

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Richard Huxton <dev(at)archonet(dot)com>
Cc: "W(dot)B(dot)Hill" <bill(at)hillzaa1(dot)miniserver(dot)com>,pgsql-general(at)postgresql(dot)org
Subject: Re: Inconsistant DOW...
Date: 2004-06-28 18:04:59
Message-ID: 29179.1088445899@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-general
Richard Huxton <dev(at)archonet(dot)com> writes:
> W.B.Hill wrote:
>> SELECT d+'45 days ago'::interval FROM test;
>> 
>> Why the different times??? Why the times???

> At a guess, the date is being converted into a timestamp with timezone 
> so you can add the interval to it.

Yeah, I think that will be the preferred conversion (and the fact that
the output shows a timezone offset is a dead giveaway ;-))

However there is also a timestamp-without-timezone plus interval
operator, so one good solution is to explicitly cast the date to
timestamp without tz and then add the interval.

Another and probably even better solution for this problem is to forget
timestamps and intervals, and use the date plus/minus integer operators
(ie, write "d - 45").  If you don't care about sub-day resolution there
is no reason to get into timestamps at all.

BTW, since 7.3 there has been a date-plus-interval operator yielding
timestamp without time zone, which I believe Lockhart added specifically
to avoid the unwanted promotion to timestamptz in this scenario.
So the third answer is to update to something less ancient than PG 7.2.

			regards, tom lane

In response to

Responses

pgsql-general by date

Next:From: Tom LaneDate: 2004-06-28 18:10:22
Subject: Re: Performance problem on RH7.1
Previous:From: Együd CsabaDate: 2004-06-28 17:53:13
Subject: Re: Performance problem on RH7.1

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