Oracle将秒数转换为小时:分钟:秒

问题描述:

我需要从给定的总秒数值中以Hours:Minutes:Seconds格式显示用户可用时间.如果您知道ORACLE函数可以执行相同的操作,则不胜感激.我正在使用Oracle.

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.

谢谢您的时间.

如果您只是想将给定的秒数转换为HH:MI:SS格式,则应该这样做

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

其中x是秒数.