Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any way in XQuery to get the current time in milliseconds since some Epoch?

Tags:

xpath

xquery

XQuery offers various date/time functions like current-dateTime(), however I can't seem to find one which gives me the time in milliseconds since Epoch. Functions to extract hours, minutes and seconds seem to exist too individually.

What is the right way to get the Epoch time (i.e. unix time or similar) in XQuery?

like image 937
jbx Avatar asked Sep 20 '11 08:09

jbx


People also ask

How do I get system time in milliseconds?

To get the current time in milliseconds, you just need to convert the output of Sys. time to numeric, and multiply by 1000.

How do you add milliseconds to epoch time?

You need to multiply it by 1000 before adding a millisecond to it.

Does Unix timestamp have milliseconds?

Datetime Unix timestamp contains milliseconds.

How do I get Epoch time from date?

Convert from human-readable date to epochlong epoch = new java.text.SimpleDateFormat("MM/dd/yyyy HH:mm:ss").parse("01/01/1970 01:00:00").getTime() / 1000; Timestamp in seconds, remove '/1000' for milliseconds.


2 Answers

thank you for the tips. I modify the code for Oracle Service Bus 11g (OSB 11g) Xpath editor in case someone else needs it

{ (fn:current-dateTime() - xs:dateTime("1970-01-01T00:00:00-00:00")) div xdt:dayTimeDuration("PT0.001S") }
like image 117
Aditya Avatar answered Oct 18 '22 01:10

Aditya


(current-dateTime() - xs:dateTime("1970-01-01T00:00:00-00:00")) div xs:dayTimeDuration('PT0.001S')

returns the number of seconds as a duration, and then divides by 1 millisecond to get the number of milliseconds as a number.

like image 24
Michael Kay Avatar answered Oct 18 '22 01:10

Michael Kay