Forum OpenACS Q&A: Response to Epoch from Oracle

Collapse
Posted by Paul Sharples on
How about:
        86400 * (some_date_col - TO_DATE('01.01.1970','DD.MM.YYYY'))


Consider this example from the Postgres documentation:
   SELECT EXTRACT(EPOCH FROM TIMESTAMP '2001-02-16 20:38:40');
   Result: 982352320


Plugging it into the Oracle version:
   SQL> SELECT 86400 * (TO_DATE('16.02.2001:20:38:40','DD.MM.YYYY:HH24:MI:SS')-
                        TO_DATE('01-JAN-1970','DD-MON-YYYY')) x
          FROM dual;

            X
   ----------
    982355920

   SQL>
Which is exactly 3600 seconds out. Hmm. Who want to be the first to point the finger?

Paul