Example of ORACLE millisecond to date conversion

  • 2021-12-04 20:10:24
  • OfStack

Milliseconds to date


SELECT TO_CHAR(1406538765000 / (1000 * 60 * 60 * 24) + 
TO_DATE('1970-01-01 08:00:00', 'YYYY-MM-DD HH:MI:SS'), 'YYYY-MM-DD HH24:MI:SS') AS CDATE 
FROM DUAL;

Date conversion milliseconds


SELECT TO_NUMBER(TO_DATE('2014-07-28 17:12:45', 'YYYY-MM-DD HH24:MI:SS') - 
TO_DATE('1970-01-01 8:0:0', 'YYYY-MM-DD HH24:MI:SS')) * 24 * 60 * 60 * 1000 
FROM DUAL;

Get the current system time


select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;

Note: The time to convert milliseconds to date formatting can be 12-hour and 24-hour.


Related articles: