Poonam
Poonam

Reputation: 23

Incorrect results while using cts:element-range-query on last-modified property and how to bind external variables in XQuery

I am creating an AdhocQuery as:session.newAdhocQuery("cts:search(fn:collection(),cts:properties-query(cts:element-range-query(xs:QName(\"prop:last-modified\"),\"<\",current-dateTime() - xs:dayTimeDuration(\"P1D\"))))");

value of current-dateTime : 2014-05-15T20:27:34.468+05:30

Still results are returned with last-modified date less than current date time. Below are some sample results:

/content/1878818.doc 2014-05-12T19:59:16+05:30

/content/1878965.doc 2014-05-12T19:59:16+05:30

/content/1878105.doc 2014-05-12T19:55:48+05:30

And 1 more thing instead of current-dateTime() how can I use some other dateTime in an XQuery.

Thanks,

Poonam

Upvotes: 0

Views: 277

Answers (1)

wst
wst

Reputation: 11771

Your query will return documents "up to one day in the past", which includes the the values you see in your results, since they all occur before xs:dateTime('2014-05-14T20:27:34.468+05:30').

To create xs:dateTime values, you can cast a string as a dateTime: xs:dateTime('2014-05-12T19:59:16+05:30') or by using a special 2-parameter constructor: fn:dateTime($arg1 as xs:date?, $arg2 as xs:time?). There are dozens of helper functions in the spec for manipulating date and time values (see http://www.w3.org/TR/xpath-functions/). MarkLogic also has a built-in helper function called xdmp:parse-dateTime that simplifies this a bit.

Upvotes: 2

Related Questions