Re: April 1

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: April 1
Дата
Msg-id 24284.1015208451@sss.pgh.pa.us
обсуждение исходный текст
Ответ на April 1  ("Andrew Bartley" <abartley@evolvosystems.com>)
Список pgsql-general
"Andrew Bartley" <abartley@evolvosystems.com> writes:
> I'm having trouble calculating a date of April 1 2002.

What is the daylight savings transition day in your timezone?
(I'm betting March 31.)

> It seems as though the "+ interval('1 day'))" only adds 23 hours rather tha=
> n 24.

No, interval('1 day') is exactly 24 hours.  But March 31 is longer than
24 hours.  You're computing March 31 23:00 hours, and then truncating
that back to March 31.

If you want to calculate at the date level I'd suggest calculating with
dates, not timestamps.

regression=# select date('2002-03-31') + 1;
  ?column?
------------
 2002-04-01
(1 row)

            regards, tom lane

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

Предыдущее
От: Samik Raychauhduri
Дата:
Сообщение: Conditional Statement
Следующее
От: Medi Montaseri
Дата:
Сообщение: Re: Conditional Statement