Re: possibly a bug?

From: "Josh Berkus" <josh(at)agliodbs(dot)com>
To: Ewald Geschwinde <webmaster(at)geschwinde(dot)net>, pgsql-novice(at)postgresql(dot)org
Subject: Re: possibly a bug?
Date: 2002-01-30 23:29:47
Message-ID: web-680587@davinci.ethosmedia.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Ewald,

> Is this a bug or Am i Wrong?

It's not a bug, it's a feature :-)

Your problem is that you're convertng back and forth between DATE
(which does not track hours) and TIMESTAMP + INTERVAL, which does
track hours. Therefore you arrive at this problem:

> beta=# SELECT ('2001-10-28'::date + '1 day'::interval)::date;
> ?column?
> ------------
> 2001-10-28
> (1 row)

Ah, but you're not seeing the whole story:

beta=# SELECT ('2001-10-28'::date + '1 day'::interval)::TIMESTAMP
?column?
------------
2001-10-28 23:00:00
(1 row)

Aha! And, if we look at a calendar, we see that 10.28.2001 was the end
of daylight savings time in 2001!

For your purposes, it would be better not to muddy the waters by
tinkering with the vagaries of TIMESTAMP. Thus, you should:

SELECT ('2001-10-28'::DATE + 1);
?column?
------------
2001-10-29
(1 row)

FOr more info, see my DATE/TIME FAQ on http://techdocs.postgtresql.org/

-Josh

______AGLIO DATABASE SOLUTIONS___________________________
Josh Berkus
Complete information technology josh(at)agliodbs(dot)com
and data management solutions (415) 565-7293
for law firms, small businesses fax 621-2533
and non-profit organizations. San Francisco

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Raphael Bauduin 2002-01-31 10:01:48 grant on tables
Previous Message Tom Lane 2002-01-30 23:27:46 Re: possibly a bug?