Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

elapsed time in milliseconds between timestamps

384260Oct 31 2003 — edited Oct 31 2003
I'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?
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 28 2003
Added on Oct 31 2003
4 comments
1,100 views