Skip to content

Instantly share code, notes, and snippets.

@arolle
Created August 19, 2014 18:49
Show Gist options
  • Save arolle/57c6a76c4586493e5eee to your computer and use it in GitHub Desktop.
Save arolle/57c6a76c4586493e5eee to your computer and use it in GitHub Desktop.
XQuery: Unix timestamp from dateTime
(:~
: unix time from dateTime
: @param dateTime
: @return unix timestamp of the supplied datetime
:)
declare local:dateTime-to-timestamp(
$dateTime as xs:dateTime
) as xs:integer {
let $dayZero := xs:dateTime('1970-01-01T00:00:00-00:00')
return
($dateTime - $dayZero) div xs:dayTimeDuration('PT1S')
}
()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment