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




nVector25-Jan-20

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

BlackPearl
BlackPearl28-Feb-20

Hi Azharuddink can you use this

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

riddhima19-Nov-20

Hi, it'll be very helpful if you could explain what you did?

AzharuddinK03-Mar-20

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)

nVector03-Mar-20

Thank you for posting the answer. Its helpful