Support Questions

Find answers, ask questions, and share your expertise

How to convert hh:mm:ss to seconds in impala?

avatar
New Contributor

How to convert hh:mm:ss format to seconds in impala? 

Eg: I have a string column as 00:01:30 (hh:mm:ss), I want it to convert to seconds as 90

 

Time (Input)Seconds (Output)
00:01:30          90
00:01:00          60
00:00:30          30
01:00:00  3600
01:00:01  3601

 

 

    

1 REPLY 1

avatar
Master Collaborator

Hi @AkhilD

Try with this indirect method:

SELECT split_part(input, ':', 1)*3600 + split_part(input, ':', 2)*60 + split_part(input, ':', 3)
FROM   your_table;

Good luck.