I have a String
in this format: 2018-11-01T00:00:00-07:00
and I would like to convert it to a TIMESTAMP
and insert it into a TIMESTAMP
column. However, when I insert it, it drops the -07:00
without first converting it to -00:00
. How do I ensure that it is converted and stored in Redshift properly?
Here is an example:
select ORIGINAL_DATE, TO_TIMESTAMP(ORIGINAL_DATE,'YYYY-MM-DD HH24:MI:SS') FROM CDW_LANDING.X where id = XXXXXX;
=> 2018-11-01T00:00:00-07:00 2018-10-31 17:00:00
The TO_TIMESTAMP
converts it to 2018-10-31 17:00:00
which is what I want. However, when I insert it, it becomes 2018-11-01 00:00:00
and simply drops the -07:00
.
Here is the example:
insert into cdw_stage.X (ORIG_DT)
select TO_TIMESTAMP(ORIGINAL_DATE,'YYYY-MM-DD HH24:MI:SS')
from CDW_LANDING.INVOICE where id = XXXXXX;
But when I query it with select ORIG_DT from cdw_landing.X;
, it displays 2018-11-01 00:00:00
. What I would like to see is 2018-10-31 17:00:00
which is what the TO_TIMESTAMP
function should do.
The ORIG_DT
in Redshift is in TIMESTAMP
format. The input date is in VARCHAR
.
How do I get Redshift to save this correctly? I also added postgres tag because Redshift is based off of postgres. Thank you so much!!!