Hi Kari, Looks like you misplaced one of the parentheses. Make sure to wrap the string "2017-09-22T08:00:00Z” in xs:dateTime(..) before you try to substract the duration. In provided query you have the xs dateTime cast wrapping both current-date and the duration.
Cheers, Geert From: <[email protected]<mailto:[email protected]>> on behalf of Kari Cowan <[email protected]<mailto:[email protected]>> Reply-To: MarkLogic Developer Discussion <[email protected]<mailto:[email protected]>> Date: Friday, September 22, 2017 at 4:51 PM To: MarkLogic Developer Discussion <[email protected]<mailto:[email protected]>> Subject: [MarkLogic Dev General] Querying DateTime values 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.
_______________________________________________ General mailing list [email protected] Manage your subscription at: http://developer.marklogic.com/mailman/listinfo/general
