21 Jan 20 · AzharuddinK · #Snowflake ·   Bookmark   ×

Need to convert this hh:mm:ss data into seconds. Is there any function available in snowflake ?

So i have a requirement to convert the below datetime format to seconds all together (10 hours 29 minutes and 14 seconds) to seconds all together at once

10:29:14

AzharuddinK

posted on 21 Jan 20

Enjoy great content like this and a lot more !

Signup for a free account to write a post / comment / upvote posts. Its simple and takes less than 5 seconds




Were you able to find a solution ? If yes, can you kindly share

BlackPearl

Hi Azharuddink can you use this

 CAST(SHIP_DT AS TIMESTAMP(0)) + (SHIP_TM - TIME '00:00:00' HOUR TO SECOND) AS SHIP_DTTM

I did it this way 

substr(substr(a.CONNECTING_TIME,0,2)*3600 + substr(a.CONNECTING_TIME,4,2)*60 + substr(a.CONNECTING_TIME,7,2),1,charindex('.',substr(a.CONNECTING_TIME,0,2)*3600 + substr(a.CONNECTING_TIME,4,2)*60 + substr(a.CONNECTING_TIME,7,2),1)-1)

Thank you for posting the answer. Its helpful


Community Software by Hittly
Copied