dbTalk Databases Forums  

Re: [BUGS] Problem with interval

mailing.database.pgsql-bugs mailing.database.pgsql-bugs


Discuss Re: [BUGS] Problem with interval in the mailing.database.pgsql-bugs forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Michael Fuhr
 
Posts: n/a

Default Re: [BUGS] Problem with interval - 10-06-2004 , 04:49 PM






On Wed, Oct 06, 2004 at 04:26:06PM -0400, Bruno Pr?vost wrote:
Quote:
I'm using postgres version 7.4.5 and had a problem with interval

Here is my query :
select '2004/10/31'::timestamptz + '1 day'::interval;

Here is the answer :
10/31/2004 11:00:00 PM
I'd guess that Daylight Saving Time is the culprit -- most places
that use it revert to Standard Time on 31 Oct this year. Suppose
you're in the EST5EDT time zone, which is 4 hours behind UTC during
the summer. '2004/10/31'::timestamptz is '2004-10-31 00:00:00-04'.
If you add one day, that would be '2004-11-01 00:00:00-04'. Only
by then you're 5 hours behind UTC instead of 4 hours behind, so the
time becomes '2004-10-31 23:00:00-05', which is the same time adjusted
for your time zone.

--
Michael Fuhr
http://www.fuhr.org/~mfuhr/

---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

http://archives.postgresql.org


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: [BUGS] Problem with interval - 10-06-2004 , 04:54 PM






=?iso-8859-1?Q?Bruno_Pr=E9vost?= <bp (AT) interaction (DOT) ws> writes:
Quote:
I'm using postgres version 7.4.5 and had a problem with interval

Here is my query :
select '2004/10/31'::timestamptz + '1 day'::interval;

Here is the answer :
10/31/2004 11:00:00 PM
If you are in a US time zone then that's the expected answer, because
2004/10/31 is a DST transition day. '1 day' is currently always taken
to mean '24 hours', and 2004/10/31 is in fact 25 hours long...

Personally I would like to see the interval type redone so that days are
separate from smaller units and this case behaves more intuitively.
But that's been on the wish list for years and it's not gotten to the
top of anyone's to-do list.

In the meantime, you might ask yourself if you really want to use
type timestamptz at all, as opposed to date. ('2004/10/31'::date + 1
would give the answer you want.) Or consider using timestamp without
time zone.

regards, tom lane

---------------------------(end of broadcast)---------------------------
TIP 2: you can get off all lists at once with the unregister command
(send "unregister YourEmailAddressHere" to majordomo (AT) postgresql (DOT) org)


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.