Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get millis of timestamp since 1970 UTC in Oracle SQL? [duplicate]

I have a table which one of the columns is of type TIMESTAMP(6).

How do I get the milliseconds of the column's data since 1970 UTC?

like image 464
AlikElzin-kilaka Avatar asked Dec 01 '25 00:12

AlikElzin-kilaka


2 Answers

Try this

select (cast(your_column as date) - date '1970-01-01')*24*60*60 from your_table;
like image 68
StephaneM Avatar answered Dec 03 '25 15:12

StephaneM


select 
  MY_TS as orig
  , extract(day from (MY_TS-to_timestamp_tz('01-01-70 0', 'DD-MM-RR TZH')))*1000*60*60*24
  + extract(hour from (MY_TS-to_timestamp_tz('01-01-70 0', 'DD-MM-RR TZH')))*1000*60*60
  + extract(minute from (MY_TS-to_timestamp_tz('01-01-70 0', 'DD-MM-RR TZH')))*1000*60
  + extract(second from (MY_TS-to_timestamp_tz('01-01-70 0', 'DD-MM-RR TZH')))*1000
    as millis
from MY_TABLE;
like image 41
AlikElzin-kilaka Avatar answered Dec 03 '25 14:12

AlikElzin-kilaka



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!