[MarkLogic Dev General] Querying DateTime values

Kari Cowan kcowan at alm.com
Fri Sep 22 07:51:59 PDT 2017


I need some expert tips on this bug.

cts:element-attribute-range-query(xs:QName("PUBLICATION-DATE"),xs:QName("datetime"),
">=", xs:dateTime(fn:current-date() - xs:dayTimeDuration("P30D")))

The above query works fine when the publication-date is in this format:
<PUBLICATION-DATE date="2017-09-28"
datetime="2017-09-28T00:00:00-04:00">2017-09-28
00:00:00:000</PUBLICATION-DATE>

But it fails when
<PUBLICATION-DATE date="2003-08-01"
datetime="2003-08-01T08:00:00Z">2003-08-01T08:00:00Z</summary:PUBLICATION-DATE>

The datetime format is different, but if I manipulate the current-date to
match that format, the query will fail with this message:

[1.0-ml] XDMP-EXPR: (err:XPTY0004) "2017-09-22T08:00:00Z" -
xs:dayTimeDuration("P30D") -- Invalid expression

How would I write the query to properly compare the dates?

The goal above was to return content from the last 30 days.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://developer.marklogic.com/pipermail/general/attachments/20170922/b92cf1bf/attachment.html 


More information about the General mailing list