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

前端 未结 3 397
情书的邮戳
情书的邮戳 2021-02-04 11:00

XQuery offers various date/time functions like current-dateTime(), however I can\'t seem to find one which gives me the time in mi

相关标签:
3条回答
  • 2021-02-04 11:24

    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") }
    
    0 讨论(0)
  • 2021-02-04 11:40

    Additional tricks on Aditya's answer for OSB 11g.

    There has an annoying bug on XQ Editors that will change div and operator into a , (comma).

    Just put a conversion function in front of that code. such as xs:long, xs:string

    ex.

    { xs:long((fn:current-dateTime() - xs:dateTime("1970-01-01T00:00:00-00:00")) div xdt:dayTimeDuration("PT0.001S")) }
    
    0 讨论(0)
  • 2021-02-04 11:42
    (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.

    0 讨论(0)
提交回复
热议问题