How to format seconds as integer into hh:mm:ss in presto?

by elise_daugherty , in category: Third Party Scripts , 14 days ago

How to format seconds as integer into hh:mm:ss in presto?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dedrick , 13 days ago

@elise_daugherty 

To format seconds as an integer into hh:mm:ss in Presto, you can use the following query:

1
2
3
4
SELECT 
    CAST(seconds / 3600 AS VARCHAR) || ':' || CAST((seconds % 3600) / 60 AS VARCHAR) || ':' || CAST(seconds % 60 AS VARCHAR) AS formatted_time
FROM 
    your_table;


Replace your_table with the name of your table and seconds with the column containing the seconds you want to format. This query will convert the seconds into hours, minutes, and seconds format (hh:mm:ss).