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

Convert nanoseconds string to timestamp in snowflake

I have timestamp in following string format: {"_nanoseconds":784000000,"_seconds":1644007937} , I want to convert them to TIMESTAMP format in snowflake. Is there anyway to do it?
I try with TO_TIMESTAMP but doesn’t work.

>Solution :

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

TO_TIMESTAMP(integer) could be used:

If the format of the input parameter is a string that contains an integer:

After the string is converted to an integer, the integer is treated as a number of seconds, milliseconds, microseconds, or nanoseconds after the start of the Unix epoch (1970-01-01 00:00:00.000000000 UTC).

If the integer is less than 31536000000 (the number of milliseconds in a year), then the value is treated as a number of seconds.

If the value is greater than or equal to 31536000000 and less than 31536000000000, then the value is treated as milliseconds.

If the value is greater than or equal to 31536000000000 and less than 31536000000000000, then the value is treated as microseconds.

If the value is greater than or equal to 31536000000000000, then the value is treated as nanoseconds.

SELECT TO_TIMESTAMP('1644007937');

Output:

enter image description here

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