Oracle Convert Seconds to Hours:Minutes:Seconds

前端 未结 14 1182
再見小時候
再見小時候 2020-12-08 06:01

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 d

14条回答
  •  醉酒成梦
    2020-12-08 06:35

    The following code is less complex and gives the same result. Note that 'X' is the number of seconds to be converted to hours.

    In Oracle use:

    SELECT TO_CHAR (TRUNC (SYSDATE) + NUMTODSINTERVAL (X, 'second'),
                    'hh24:mi:ss'
                   ) hr
      FROM DUAL;
    

    In SqlServer use:

    SELECT CONVERT(varchar, DATEADD(s, X, 0), 108);
    

提交回复
热议问题