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

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 (view raw or flat)
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

pgsql-novice by date

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

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