ORACLE: Convert milliseconds to date or Reverse convert

1. Oracle 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;

2. Oracle date to miliseconds

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;

你可能感兴趣的:(Oracle,oracle,数据库)