Skip to content

Instantly share code, notes, and snippets.

@prestonmcgowan
Created October 10, 2019 18:46
Show Gist options
  • Save prestonmcgowan/449774137b15f013e528861afb3e2c2a to your computer and use it in GitHub Desktop.
Save prestonmcgowan/449774137b15f013e528861afb3e2c2a to your computer and use it in GitHub Desktop.
Convert epoch time to xs:dateTime in XQuery
let $epoch := 1397215825
let $dtd := xs:dayTimeDuration(fn:concat('PT', $epoch, 'S'))
let $dt := xs:dateTime("1970-01-01T00:00:00-00:00") + $dtd
let $re-epoch := ( $dt - xs:dateTime("1970-01-01T00:00:00-00:00") ) div xs:dayTimeDuration('PT1S')
return ($epoch, $dt, $re-epoch)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment