2017-07-07 9 views
0

私のpostgresクエリでタイムゾーンを自動的に計算しようとしています。私の目標は、0時から23時59分(ESTまたはUTC - 5:00)のレコードを選択することです。postgresクエリのタイムゾーンの計算

現在のクエリでは、UTC時刻の0時から23時59分までのレコードしか返しません。デフォルトではtimestamp without timezone

SELECT pg_typeof("start_time") from routes limit 1; 

戻っUTCであるので

select path, start_time from routes where routes.network_id = 1 and routes.start_time between '2017-06-13 00:00:00'::timestamp AND '2017-06-13 23:59:59'::timestamp 

start_timeは1つが5時間差を考慮してクエリを記述して変換する方法を、タイムゾーンなしのタイムスタンプですstart_time〜UTC - 5?

+0

これはPostgresのです –

答えて

1

これを試してみてください:

select path, start_time - interval '5 hours' as start_time_est 
    from routes 
where routes.network_id = 1 
     and routes.start_time between '2017-06-13 00:00:00-5'::timestamp with time zone 
      AND '2017-06-13 23:59:59-5'::timestamp with time zone; 
関連する問題