Re: to_char(date '2001-04-01', 'dd') results in 31 -- why?

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: to_char(date '2001-04-01', 'dd') results in 31 -- why?
Дата
Msg-id 26195.979491008@sss.pgh.pa.us
обсуждение исходный текст
Ответ на to_char(date '2001-04-01', 'dd') results in 31 -- why?  (Fred Yankowski <fred@ontosys.com>)
Список pgsql-general
Fred Yankowski <fred@ontosys.com> writes:
> In PostgreSQL 7.0.3 (on NT), the expression
>     to_char(date '2001-04-01', 'dd')
> evaluates to '31', which is a bit surprising.

It's just a bug: date to timestamp conversion did the wrong thing on
DST forward transition days in 7.0.3 and before.  It's fixed for 7.1.

In EST5EDT time zone, 7.0.* gives:

play=> select timestamp(date '2001-03-31') ;
       timestamp
------------------------
 2001-03-31 00:00:00-05                -- correct
(1 row)

play=> select timestamp(date '2001-04-01') ;
       timestamp
------------------------
 2001-03-31 23:00:00-05                -- off by 1 hour
(1 row)

play=> select timestamp(date '2001-04-02') ;
       timestamp
------------------------
 2001-04-02 00:00:00-04                -- correct
(1 row)

but current sources (7.1beta3) give:

regression=# select timestamp(date '2001-03-31') ;
       timestamp
------------------------
 2001-03-31 00:00:00-05
(1 row)

regression=# select timestamp(date '2001-04-01') ;
       timestamp
------------------------
 2001-04-01 00:00:00-05
(1 row)

regression=# select timestamp(date '2001-04-02') ;
       timestamp
------------------------
 2001-04-02 00:00:00-04
(1 row)


            regards, tom lane

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: fatal error - different CATALOG_VERSION_NO
Следующее
От: "Thomas T. Thai"
Дата:
Сообщение: Re: performance hit with --enable-debug