Re: mark the timestamptz variant of date_bin() as stable

Поиск
Список
Период
Сортировка
От John Naylor
Тема Re: mark the timestamptz variant of date_bin() as stable
Дата
Msg-id CAFBsxsH4uTJN=vyQ+7Wj=uwYXym3epfGjzdDyzi3Xm7F=ShfpA@mail.gmail.com
обсуждение исходный текст
Ответ на Re: mark the timestamptz variant of date_bin() as stable  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: mark the timestamptz variant of date_bin() as stable  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers

On Wed, Sep 1, 2021 at 2:44 PM Tom Lane <tgl@sss.pgh.pa.us> wrote:

> regression=# set timezone to 'America/New_York';
> SET
> regression=# select date_bin('1 day', '2021-11-01 00:00 +00'::timestamptz, '2021-09-01 00:00 -04'::timestamptz);
>         date_bin      
> ------------------------
>  2021-10-31 00:00:00-04
> (1 row)
>
> regression=# select date_bin('1 day', '2021-11-10 00:00 +00'::timestamptz, '2021-09-01 00:00 -04'::timestamptz);
>         date_bin      
> ------------------------
>  2021-11-08 23:00:00-05
> (1 row)
>
> I see that these two answers are both exactly multiples of 24 hours away
> from the given origin.  But if I'm binning on the basis of "days" or
> larger units, I would sort of expect to get local midnight, and I'm not
> getting that once I cross a DST boundary.

Hmm, that's seems like a reasonable expectation. I can get local midnight if I recast to timestamp:

# select date_bin('1 day', '2021-11-10 00:00 +00'::timestamptz::timestamp, '2021-09-01 00:00 -04'::timestamptz::timestamp);
      date_bin
---------------------
 2021-11-09 00:00:00
(1 row)

It's a bit unintuitive, though.

--
John Naylor
EDB: http://www.enterprisedb.com

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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: mark the timestamptz variant of date_bin() as stable
Следующее
От: Tom Lane
Дата:
Сообщение: Re: mark the timestamptz variant of date_bin() as stable