Delete documents less than 30 days in Marklogic Xquery
I was searching over the internet to find how to return documents less than 1 month old from the current date and i found the above link. Since there are no range indexes for the element i am using
let $currentdt := fn:current-dateTime()
let $amonthAgo := $currentdt- xs:yearMonthDuration("P1M")
cts:search(doc(),
cts:element-query(xs:QName("myDateTimeField"), cts:true-query())
)[.//myDateTimeField[xs:dateTime(.) eq $amonthAgo]]
returns nothing.
I have sample values such as
2021-05-18T06:32:34.761729-04:00
2021-05-15T06:32:34.761729-04:00
2021-03-19T06:32:34.761729-04:00
2021-06-15T06:32:34.761729-04:00
TIA!