2

I have requirement to get previous date of one of the date field, for that I am doing below operation in TDE. But I am getting error on this operation. How can I achieve this

<tde:column>
<tde:name>PreStartDate</tde:name>
<tde:scalar-type>date</tde:scalar-type>
<tde:val>(hdm:StartDate - xs:dayTimeDuration("P1D"))</tde:val>
<tde:nullable>true</tde:nullable>
</tde:column>
ramz123
  • 207
  • 1
  • 8
  • What error is shown? Have you tried testing your TDE from QConsole against a sample document? You may need to cast the value of your StartDate element to xs:date or xs:dateTime if you don't have an XML Schema loaded into MarkLogic that specifies its type. – grtjn Feb 24 '21 at 08:43
  • hdm:StartDate is already in Date format – ramz123 Feb 24 '21 at 08:57

1 Answers1

3

I see your comment stating that hdm:StartDate is already in Date format. As written, however, what you have is a string that looks like a Date (well, more precisely an untypedAtomic). It needs to be converted to an actual date type before you can subtract a dayTimeDuration from it.

<tde:column>
  <tde:name>PreStartDate</tde:name>
  <tde:scalar-type>date</tde:scalar-type>
  <tde:val>(xs:date(hdm:StartDate) - xs:dayTimeDuration("P1D"))</tde:val>
  <tde:nullable>true</tde:nullable>
</tde:column>
Dave Cassel
  • 8,352
  • 20
  • 38