Skip to content

Instantly share code, notes, and snippets.

@vlcinsky
Created July 18, 2011 23:09
Show Gist options
  • Save vlcinsky/1090919 to your computer and use it in GitHub Desktop.
Save vlcinsky/1090919 to your computer and use it in GitHub Desktop.
filtering documents based on custom date format in XQuery
for $doc in //Document
let $datestr := $doc/@time
let $datearr := tokenize($datestr, '/')
let $year := $datearr[3]
let $month := format-number(xs:int($datearr[2]), '#00')
let $day := format-number(xs:int($datearr[1]), '#00')
let $dateisostr := concat($year, '-', $month, '-', $day)
where $dateisostr > '2010-06-01' and $dateisostr < '2011-01-01'
(:
let $date := xs:date($dateisostr)
where $date > xs:date('2010-06-01') and $date < xs:date('2011-01-01')
:)
return $doc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment