elapsed time in milliseconds between timestamps
384260Oct 31 2003 — edited Oct 31 2003I'm trying to get the elapsed time in milliseconds from a timestamp and the epoch. I've got a hacky solution that works, but I'm wondering if there is a simpler way. Here is what I have so far:
SELECT
(
SUBSTR(TO_CHAR(REQUEST_TIME - to_timestamp('01-jan-1970 00:00:00.00','dd-mon-yyyy hh24:mi:ss.ff')),0,10) * 24 * 60 * 60 * 1000
+ (TO_CHAR(REQUEST_TIME,'HH24') * 60 * 60 * 1000)
+ (TO_CHAR(REQUEST_TIME,'MI') * 60 * 1000)
+ (TO_CHAR(REQUEST_TIME,'SS') * 1000)
+ SUBSTR(TO_CHAR(REQUEST_TIME,'FF'),0,4)
) + (6 * 60 * 60 * 1000) ELAPSED_MS_FROM_EPOCH_GMT
FROM ORDER_FACT;
Note: I'm adding six hours to get GMT time.
Any ideas?