day_trunc and day duration in a remote time zone

Поиск
Список
Период
Сортировка
От Marc Mamin
Тема day_trunc and day duration in a remote time zone
Дата
Msg-id B6F6FD62F2624C4C9916AC0175D56D880CE2B75C@jenmbs01.ad.intershop.net
обсуждение исходный текст
Ответы Re: day_trunc and day duration in a remote time zone  (Adrian Klaver <adrian.klaver@gmail.com>)
Список pgsql-general
Hello,
I want to retrieve the day start and duration of an epoch  within a given time zone
and return the day start as epoch.
 
the queries below works as expected, but I would  appreciate a simpler solution ...
 
example:
 
 
        select (TIMESTAMP WITH TIME ZONE 'epoch' + interval '1382886336 seconds') AT TIME ZONE 'Europe/Nicosia'
        2013-10-27 17:05:36
 
 
 
SELECT
EXTRACT (epoch FROM cast(date( (TIMESTAMP WITH TIME ZONE 'epoch' + interval '1382886336 seconds' ) 
AT TIME ZONE 'Europe/Nicosia') || ' 00:00 Europe/Nicosia' as timestamptz)) as day_start
 
=> 1382821200
 
 
SELECT
(
        EXTRACT (epoch FROM cast(date( (TIMESTAMP WITH TIME ZONE 'epoch' + interval '1382983536 seconds' /* added 27 hours to the previous day_start result */ ) 
        AT TIME ZONE 'Europe/Nicosia') || ' 00:00 Europe/Nicosia' as timestamptz))
        -
        1382821200 /* = day_start*/
)/3600 as hour_duration
 
=> 25 hours, which is correct as the daylight saving time ends at this date
 
 
 
regards,
 
Marc Mamin
 

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

Предыдущее
От: Victor Yegorov
Дата:
Сообщение: Re: Idle transactions in PostgreSQL 9.2.4
Следующее
От: Oscar Calderon
Дата:
Сообщение: Strange results with pg_restore