[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

parsing dates

Joe Wicentowski joewiz at gmail.com
Tue Oct 6 12:59:37 PDT 2009


  parsing dates
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!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.