Md Shahnawaz Alam
Md Shahnawaz Alam

Reputation: 25

how to convert this time 2007-10-01T01:02:03.004 into datetime in snowflake

2007-10-01T01:02:03.004 convert into datetime in snowflake

i used yyyymmddhh24miss

2022-11-03 09:13:48.000

Upvotes: 0

Views: 32

Answers (1)

Alexander Klimenko
Alexander Klimenko

Reputation: 1695

This type of input time format is automatically recognized. The following should work:

select to_timestamp_ntz('2007-10-01T01:02:03.004');

the output will depend on the output data format set as a session parameter, e.g.:

alter session set timestamp_ntz_output_format = 'YYYY-MM-DD HH24:MI:SS.FF3';

Therefore the select statement above will output:

2007-10-01 01:02:03.004

doc refference

To manipulate the actual timestamp value, you can use the DATEADD() function, e.g.:

select dateadd(months, 175, to_timestamp_ntz('2007-10-01T01:02:03.004')) as result;

Output:

2022-05-01 01:02:03.004

Doc refference

Upvotes: 1

Related Questions