Re: possibly a bug?

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Ewald Geschwinde <webmaster(at)geschwinde(dot)net>
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: possibly a bug?
Date: 2002-01-30 23:27:46
Message-ID: 27628.1012433266@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

Ewald Geschwinde <webmaster(at)geschwinde(dot)net> writes:
> beta=# SELECT ('2001-10-28'::date + '1 day'::interval)::date;
> ?column?
> ------------
> 2001-10-28
> (1 row)

Try using date arithmetic, rather than timestamp arithmetic:

regression=# SELECT '2001-10-28'::date + 1;
?column?
------------
2001-10-29
(1 row)

The problem with the other is that type interval considers '1 day'
to mean '24 hours', which is not what you want. Since 10/28 is
a DST transition day (at least here in the USA), there's a difference.
What you're really getting is a timestamp addition:

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

which doesn't produce the desired result when you coerce the timestamp
back to date.

However, adding a plain integer to a date will do what you want.

regards, tom lane

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2002-01-30 23:29:47 Re: possibly a bug?
Previous Message Ewald Geschwinde 2002-01-30 23:05:31 possibly a bug?