Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Oracle Convert Seconds to Hours:Minutes:Seconds

I have a requirement to display user available time in Hours:Minutes:Seconds format from a given total number of seconds value. Appreciate if you know a ORACLE function to do the same. I'm using Oracle.

Thank you for your time.

like image 597
user1430989 Avatar asked Jun 12 '12 19:06

user1430989


2 Answers

If you're just looking to convert a given number of seconds into HH:MI:SS format, this should do it

SELECT 
    TO_CHAR(TRUNC(x/3600),'FM9900') || ':' ||
    TO_CHAR(TRUNC(MOD(x,3600)/60),'FM00') || ':' ||
    TO_CHAR(MOD(x,60),'FM00')
FROM DUAL

where x is the number of seconds.

like image 93
Mike Avatar answered Oct 21 '22 17:10

Mike


Try this one. Very simple and easy to use

select to_char(to_date(10000,'sssss'),'hh24:mi:ss') from dual;
like image 36
vogash Avatar answered Oct 21 '22 18:10

vogash