Could you provide implementation of stored function to get current systimestamp
as milliseconds.
Something I can use like
select current_time_ms from dual;
and get the difference, measured in milliseconds, between the current time and midnight, January 1, 1970 UTC.
Thanks.
Answers. Dates do not contain milliseconds, they only go as fine as seconds. You might want to try a timestamp datatype.
SYSDATE: Show the date and time of the database server. CURRENT_DATE: Show the date and time of the session timezone. SYSTIMESTAMP: Shows the date and time of the database server, in a TIMESTAMP WITH TIME ZONE data type.
select TO_CHAR(to_date('01-JAN-2013', 'DD-MON-YYYY'), 'DAY') FROM DUAL; answer was :TUESDAY. select TO_CHAR(to_date(sysdate+1, 'DD-MON-YYYY'), 'DAY') FROM DUAL; answer is :MONDAY.
SYSTIMESTAMP returns current timestamp on database server, while current_timestamp returns current timestamp on client machine. So if your database server is in New York and client box is in California, SYSTIMESTAMP will be 3 hours ahead of CURRENT_TIMESTAMP.
function current_time_ms return number is out_result number; begin select extract(day from(sys_extract_utc(systimestamp) - to_timestamp('1970-01-01', 'YYYY-MM-DD'))) * 86400000 + to_number(to_char(sys_extract_utc(systimestamp), 'SSSSSFF3')) into out_result from dual; return out_result; end current_time_ms;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With