In order to use the xs:type, the dates must be in the form "yyyy-mm-dd". For example:
<Documents> <Document id="1" time="2010-02-05"> </Document> <Document id="2" time="2011-08-04"> </Document> <Document id="3" time="2010-09-06"> </Document> <Document id="4" time="2010-10-08"> </Document> </Documents> //Document[ @time cast as xs:date > "2010-05-01" cast as xs:date and @time cast as xs:date < "2011-04-01" cast as xs:date]
Otherwise, you could install the FunctX package and use the function functx:mmddyyy-to-date() to convert the dates:
import module namespace functx="http://www.functx.com"; <Documents> <Document id="1" time="5/2/2010"> </Document> <Document id="2" time="4/8/2011"> </Document> <Document id="3" time="6/9/2010"> </Document> <Document id="4" time="8/10/2010"> </Document> </Documents> //Document[ functx:mmddyyyy-to-date(@time) > "2010-05-01" cast as xs:date and functx:mmddyyyy-to-date(@time) < "2011-04-01" cast as xs:date]
Instructions on how to install an XAR package can be found here: http://docs.basex.org/wiki/Packaging#Interacting_with_the_package_repository
The FunctX XAR file can be downloaded from here: http://files.basex.org/xar/functx-1.0.xar
Greetings, Dimitar
Am Montag, 18. Juli 2011, 18:20:00 schrieb Lusha Wang:
For example:
<Documents> <Document id="1" time="5/2/2010"> </Document> <Document id="2" time="4/8/2011"> </Document> <Document id="3" time="6/9/2010"> </Document> <Document id="4" time="8/10/2010"> </Document> </Documents>
How to query the documents that are within May 2010 to April 2011? Thanks ________________________________________ From: Dimitar Popov [Dimitar.Popov@uni-konstanz.de] Sent: Monday, July 18, 2011 1:11 PM To: basex-talk@mailman.uni-konstanz.de Cc: Lusha Wang Subject: Re: [basex-talk] help! database query for specific time period
Hi Serena,
Could you give more information about your case - I can't undestand what exactly do you want to do. Otherwise, here is a short example of using the xs:time type:
<Documents> <Document id="1" time="01:00:00"> </Document> <Document id="2" time="02:00:00"> </Document> <Document id="3" time="15:00:00"> </Document> <Document id="4" time="16:00:00"> </Document> </Documents> //Document[@time cast as xs:time > "13:00:00" cast as xs:time]
Greetings, Dimitar
Am Montag, 18. Juli 2011, 16:24:22 schrieb Lusha Wang:
Hi Guys
Is it possible to query for specific time period of data? I really
appreciate any help. <Documents>
<Document id=" " time=" "> .............. </Document> <Document id=" " time=" "> .............. </Document>
</Documents>
Sincerely Serena