Hi Pragya,
I don't think ,you can use the below format for date range comparison . Better
you have same date details in attribute too. So , simply you can setup element
attribute range index with integer option then try the following code . It will
work.
let $fromDate := ("2011-03-04")
let $toDate := ("2011-06-08")
let $docs := cts:search(fn:doc()/DocumentList/Document,
cts:and-query((
cts:element-attribute-range-query(xs:QName("Date"),xs:QName("Year"),
">=",xs:int(substring($fromDate,1,4))),
cts:element-attribute-range-query(xs:QName("Date"),xs:QName("Year"),
"<=",xs:int(substring($toDate,1,4))),
cts:element-attribute-range-query(xs:QName("Date"),xs:QName("Month"),
">=",xs:int(substring($fromDate,6,2))),
cts:element-attribute-range-query(xs:QName("Date"),xs:QName("Month"),
"<=",xs:int(substring($toDate,6,2))),
cts:element-attribute-range-query(xs:QName("Date"),xs:QName("Day"),
">=",xs:int(substring($fromDate,9,2))),
cts:element-attribute-range-query(xs:QName("Date"),xs:QName("Day"),
"<=",xs:int(substring($toDate,9,2)))
))
)
return $docs
By
Raja>>>
From: [email protected]
[mailto:[email protected]] On Behalf Of Kapoor, Pragya
Sent: Thursday, January 21, 2016 2:52 PM
To: MarkLogic Developer Discussion
Subject: [MarkLogic Dev General] cts:element-range-query
Hi,
I need to query an element(Date) using cts:element-range-query, but the value
this element(Date) is in different format.
<Date Year="2011" Month="03" Day="04">
2011 Mar 04
</Date>
query :
let $fromDate := xs:date("2011-04-08")
let $toDate := xs:date("2011-06-08")
let $docs := cts:search(fn:doc("/misc/DocList.xml")/DocumentList/Document,
cts:and-query((
cts:element-range-query(xs:QName("Date"),
"<=",$fromDate),
cts:element-range-query(xs:QName("Date"), ">=",$toDate)
))
)
return $docs
How can run this query or I need to use some other api?
Thanks
Pragya
"This e-mail and any attachments transmitted with it are for the sole use of
the intended recipient(s) and may contain confidential , proprietary or
privileged information. If you are not the intended recipient, please contact
the sender by reply e-mail and destroy all copies of the original message. Any
unauthorized review, use, disclosure, dissemination, forwarding, printing or
copying of this e-mail or any action taken in reliance on this e-mail is
strictly prohibited and may be unlawful."
This e-mail and any files transmitted with it are for the sole use of the
intended recipient(s) and may contain confidential and privileged information.
If you are not the intended recipient(s), please reply to the sender and
destroy all copies of the original message. Any unauthorized review, use,
disclosure, dissemination, forwarding, printing or copying of this email,
and/or any action taken in reliance on the contents of this e-mail is strictly
prohibited and may be unlawful. Where permitted by applicable law, this e-mail
and other e-mail communications sent to and from Cognizant e-mail addresses may
be monitored.
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general