Skip to content

Instantly share code, notes, and snippets.

@ableasdale
Created July 4, 2016 13:22
Show Gist options
  • Save ableasdale/2f675306e79cc24e0124c18269582aba to your computer and use it in GitHub Desktop.
Save ableasdale/2f675306e79cc24e0124c18269582aba to your computer and use it in GitHub Desktop.
MarkLogic / XQuery: dealing with date (duration) calculations
xquery version "1.0-ml";
declare variable $dt as xs:dateTime := fn:current-dateTime();
element data {
element current {$dt},
element current-minus-seven-days {$dt - xs:dayTimeDuration('P7D')},
element current-plus-seven-days {$dt + xs:dayTimeDuration('P7D')},
element current-plus-one-hour {$dt + xs:dayTimeDuration('PT1H')}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment