Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

timestamp "2022-01-02T12:30:30.471395746-06" is not recognized snowflake

I have a timestamp that looks like this:

2022-01-02T12:30:30.471395746-06

I tried running the following code:

alter session set timestamp_input_format = 'AUTO';
select s.$1, s.$2, to_timestamp_tz(s.$3), s.$4, s.$5
     from @my_stage s limit 10;

This gives me an error saying:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Timestamp '2022-01-02T12:30:30.471395746-06' is not recognized

I also tried setting the format to

alter session set timestamp_input_format = 'YYYY-MM-DD"T"HH24:MI:SS.FF9';
alter session set timestamp_output_format = 'YYYY-MM-DD"T"HH24:MI:SS.FF9';

which did not work. Any suggestion would be appreicated!

>Solution :

You are missing the timezone part at the end, it should be specified in the timestamp format as TZH in your case.

The following should work:

alter session set timestamp_input_format = 'YYYY-MM-DDTHH24:MI:SS.FF9TZH';

or

select to_timestamp_tz('2022-01-02T12:30:30.471395746-06', 'YYYY-MM-DDTHH24:MI:SS.FF9TZH');

Output:

2022-01-02T12:30:30.471395746-06:00

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading