【发布时间】:2015-07-01 14:19:38
【问题描述】:
我在红移表中有一个日期时间列。它包含 UTC 格式的日期。 因此,当我基于 UTC+5:30/UTC+4:30 之类的 time_zone 进行查询时,我想将表 datetime 列转换为选择的 time_zone 并继续进行。它给了我错误的结果。
使用此方法: CONVERT_TIMEZONE (['source_zone',] 'target_zone', 'timestamp')
查询类型 1:输入错误,正确答案
SELECT id, convert_timezone('UTC+5:30','UTC', date) as converted_time, ingest_date
FROM table_name
WHERE conditions
查询类型 2:输入正确,答案错误 -> 再次从列中的日期中减去 5:30
SELECT id , convert_timezone('UTC','UTC+5:30',ingest_date) as converted_time, ingest_date
FROM table_name
WHERE conditions
查询类型 3:输入错误,正确答案
SELECT id, convert_timezone('UTC','UTC-5:30',ingest_date) as converted_time, ingest_date
FROM table_name
WHERE conditions
如何将 UTC 列转换/解析为选定的时区?
【问题讨论】:
标签: postgresql datetime amazon-redshift