Dates and daylight saving time

Поиск
Список
Период
Сортировка
От Fduch the Pravking
Тема Dates and daylight saving time
Дата
Msg-id 20020131190353.A2946@zombie.antar.bryansk.ru
обсуждение исходный текст
Список pgsql-bugs
I got the following problem in PostgreSQL 7.1.3.

When I need to get next day relative to another one,
I do the following query:
SELECT date(date ? + interval '1 day').

But on '2001-10-28', I get this:

test=> SELECT date(date '2001-10-28' + interval '1 day');
    date
------------
 2001-10-28
(1 row)

It might look VERY strange if we don't know that the date of '2001-10-28'
is the date of switching from daylight saving time to winter time,
and before the following query is executed:

test=> SELECT timestamp(date '2001-10-28' + interval '1 day');
       timestamp
------------------------
 2001-10-28 23:00:00+03
(1 row)

Why the addition of '1 day' to some date (or timestamp) is equal to
addition of exactly 24 hours (regardless of real length of this day),
while the addition of '1 month' to some date varies depending on month's length?
And why no separate '+' operator for 'date' and 'interval' types?

How to handle such situation?


--
Fduch M. Pravking

В списке pgsql-bugs по дате отправления:

Предыдущее
От: "Peter V. Cooper"
Дата:
Сообщение: New to Postgresql - Backend timeout /JDBC
Следующее
От: "Tom Pfau"
Дата:
Сообщение: Re: Dates and daylight saving time