Re: Getting Hour From a Time in Different Time Zone

Поиск
Список
Период
Сортировка
От Tom Lane
Тема Re: Getting Hour From a Time in Different Time Zone
Дата
Msg-id 12910.1010072610@sss.pgh.pa.us
обсуждение исходный текст
Ответ на Getting Hour From a Time in Different Time Zone  ("Tom Kreiner" <tom_kreiner@hotmail.com>)
Список pgsql-sql
"Tom Kreiner" <tom_kreiner@hotmail.com> writes:
> SELECT hour(timestamp(current_timestamp AT TIME ZONE INTERVAL '-05 hours'));

The AT TIME ZONE construct produces a text string, which you are
converting back into a timestamp, which is internally just GMT --- all
notion that it had anything to do with EST time is gone.

You can actually get the above to work in 7.2, though.  It looks like
Thomas changed AT TIME ZONE to not emit timezone in the output string,
which avoids the rotation back to your own zone:


regression=# SELECT current_timestamp;         timestamptz
-------------------------------2002-01-03 10:40:42.901964-05
(1 row)

regression=# SELECT current_timestamp AT TIME ZONE INTERVAL '-08 hours';         timezone
----------------------------2002-01-03 07:40:49.452058
(1 row)

regression=# SELECT "timestamp"(current_timestamp AT TIME ZONE INTERVAL '-08 hours');        timestamp
----------------------------2002-01-03 07:41:19.469686
(1 row)

regression=# SELECT extract(hour from "timestamp"(current_timestamp AT TIME ZONE INTERVAL '-08 hours'));date_part
-----------        7
(1 row)
        regards, tom lane


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: OUTER JOIN doesn't work on pgSQL 7.1.2
Следующее
От: "Tibor Laszlo"
Дата:
Сообщение: Re: change null to 0 in SQL script