Вы должны использовать xs:dayTimeDuration
или xs:yearMonthDuration
, для которых определены операторы вычитания .
В качестве доказательства, этот XQuery:
let $now := current-dateTime()
let $month := xs:dayTimeDuration("P30D")
let $month_ago := $now - $month
return $month_ago
Вывод:
2011-03-23T14:32:47.156-03:00
Проверено на саксонской, альтовой, XQSharp.
от http://www.w3.org/TR/xpath20/#mapping, это отображение оператора:
Operator | Type(A) | Type(B) | Function
A - B | numeric | numeric | op:numeric-subtract(A, B)
A - B | xs:date | xs:date | op:subtract-dates(A, B)
A - B | xs:date | xs:yearMonthDuration | op:subtract-yearMonthDuration-from-date(A, B)
A - B | xs:date | xs:dayTimeDuration | op:subtract-dayTimeDuration-from-date(A, B)
A - B | xs:time | xs:time | op:subtract-times(A, B)
A - B | xs:time | xs:dayTimeDuration | op:subtract-dayTimeDuration-from-time(A, B)
A - B | xs:dateTime | xs:dateTime | op:subtract-dateTimes(A, B)
A - B | xs:dateTime | xs:yearMonthDuration | op:subtract-yearMonthDuration-from-dateTime(A, B)
A - B | xs:dateTime | xs:dayTimeDuration | op:subtract-dayTimeDuration-from-dateTime(A, B)
A - B | xs:yearMonthDuration | xs:yearMonthDuration | op:subtract-yearMonthDurations(A, B)`