Skip to content

Instantly share code, notes, and snippets.

@avernet
Created August 3, 2020 17:55
Show Gist options
  • Save avernet/7b9c399fb9d03655d10e976cff0db0f5 to your computer and use it in GitHub Desktop.
Save avernet/7b9c399fb9d03655d10e976cff0db0f5 to your computer and use it in GitHub Desktop.
XPath for checking date is in current fiscal year
let
$this-year-start := xs:date(concat(year-from-date(current-date()), '-07-01')),
$fiscal-start :=
if ($this-year-start <= current-date())
then $this-year-start
else $this-year-start - xs:yearMonthDuration('P1Y'),
$fiscal-end := $fiscal-start + xs:yearMonthDuration('P1Y') - xs:dayTimeDuration('P1D'),
$input-date := xs:date('2020-08-03')
return
$fiscal-start <= $input-date and
$input-date <= $fiscal-end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment