|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] parsing datesJoe Wicentowski joewiz at gmail.comTue Oct 6 12:59:37 PDT 2009
Hi James,
Got it - now I understand.
Well, if your dates are normalized to yyyy-mm-dd, I'd suggest keeping
them as is in date/@when. This way, you can set up a range index on
@when, and you can do date comparisons (<, >, =) based on the
searches. See eXist's documentation on setting up indexing, but I'd
use something like:
<create qname="@when" type="xs:date"/>
This would enable comparison queries like:
let $date := request:get-parameter("date", ("1789-01-01"))
let $query-start-date :=
if ($date castable as xs:date) then $date cast as xs:date
else if ($date castable as xs:gYearMonth) then concat($date, '-01')
cast as xs:date
else concat($date, '-01-01') cast as xs:date
let $query-end-date :=
if ($date castable as xs:date) then $date cast as xs:date
else if ($date castable as xs:gYearMonth) then concat($date,
functx:days-in-month($month)) cast as xs:date
else concat($date, '-12-31') cast as xs:date
for $hit in $docs[tei:date/@when ge $query-start-date and
tei:date/@when le $query-end-date]
...
(for the functx days-in-month function, see
http://www.xqueryfunctions.com/xq/functx_days-in-month.html)
Joe
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






