【发布时间】:2017-10-23 15:37:09
【问题描述】:
在 Aginity Workbench for AWS Redshift 上使用函数 to_timestamp() 时遇到问题。出于某种我不明白的原因,我尝试创建的时间戳增加了 2 小时。
我一直在寻找解决方案,但找不到类似的东西,有人可以帮我解决这个问题吗?
以下代码:
select
'2017-10-17 10:30:00' test,
to_timestamp('2017-10-17 10:30:00','YYYY-MM-DD HH24:MI:SS') test_converted
检索:
测试 = 2017-10-17 10:30:00
test_converted = 2017-10-17 12:30:00
【问题讨论】:
-
看起来像一个时区的东西。你是UTC+2吗? '2017-10-17 10:30:00'::timestamp 和 '2017-10-17 10:30:00'::timestamptz 和 '2017-10-17 10:30:00' 你会得到什么: :timestamptz 在时区 'UTC'
-
同意,'2017-10-17 10:30:00'::timestamptz 给出 '2017-10-17 12:30:00' 和 '2017-10-17 10:30:00 '::timestamptz 在时区'UTC' 给我'2017-10-17 10:30:00'。 “::”在做什么?如果 XX::timestamp 等于 to_timestamp(XX,'YYYY-MM-DD HH24:MI:SS') 那么它解决了我的问题。
-
请在下方查看我的回答,如果您需要,请“接受”
标签: sql amazon-redshift aginity