to_timestamp以匹配列值并从Redshift检索记录

时间:2019-07-11 10:04:33

标签: amazon-redshift

我有一个表,其中在插入记录时插入sysdate,但是当我尝试检索记录时却无法这样做。

插入历史记录表

Insert into Hist_Table
(select stg.*,sysdate from live_table stg)

从历史记录表中选择(没有错误,但没有选择记录)

select * from Hist_Table
where hist_insert_dt = TO_TIMESTAMP('2019-07-09 05:58:29','YYYY-MM-DD HH24:MI:SS')

OR

select * from Hist_Table
where hist_insert_dt = '2019-07-09 05:58:29'::timestamp

但是下面的方法有效

select * from Hist_Table
where to_char(hist_insert_dt,'YYYY-MM-DD HH24:MI:SS') = '2019-07-09 05:58:29'

不确定下面的内容为什么会给时间偏移

select to_timestamp('2019-07-09 05:58:29','YYYY-MM-DD HH24:MI:SS')

输出为:2019-07-09 11:28:29不知道为什么会给出11:28而不是05:58

我希望能够使用以下命令获取记录

select * from Hist_Table
where hist_insert_dt = TO_TIMESTAMP('2019-07-09 05:58:29','YYYY-MM-DD HH24:MI:SS')

0 个答案:

没有答案