Oracle: Convert seconds to time - hh:mi:ss


Example 1: Convert seconds to time
SQL> select
  2    to_char(
  3          trunc(sysdate)
  4          + numtodsinterval(55494, 'second')
  5      ,'hh24:mi:ss'
  6    ) time
  7  from dual;

TIME
--------
15:24:54


Example 2: Convert seconds to time
SQL> select
  2    to_char(
  3        to_date(55494,'sssss')
  4    ,'hh24:mi:ss')
  5  from dual;

TO_CHAR(
--------
15:24:54


Example 3: Convert seconds to time
SQL> select
  2      to_char(trunc(55494/3600),'fm9900') || ':' ||
  3      to_char(trunc(mod(55494,3600)/60),'fm00') || ':' ||
  4      to_char(mod(55494,60),'fm00') time
  5  from dual;

TIME
-------------
15:24:54



Related Posts
- Why to Prefer Oracle Native Date Arithmetic over ANSI INTERVAL
- Oracle: convert time hh:mi:ss to seconds
- Oracle: Some Important Date Queries
- Playing With Truncate and Date
- Oracle: Dates Difference in days, hours, minutes & seconds

No comments:

Post a Comment