XPath/XQuery subtract-yearMonthDuration-from-date function

Summary

Returns the xs:date that is a given duration before a specified xs:date (or after, if the duration is negative).

Operator Mapping

Defines the semantics of the "-" operator when applied to an xs:date and an xs:yearMonthDuration value.

Signature

op:subtract-yearMonthDuration-from-date(
$arg1 as xs:date,
$arg2 as xs:yearMonthDuration
) as xs:date

Properties

This function is deterministic, context-independent, and focus-independent.

Rules

Returns the xs:date computed by negating $arg2 and adding the result to $arg1 using the function op:add-yearMonthDuration-to-date.

Examples

The expression op:subtract-yearMonthDuration-from-date(xs:date("2000-10-30"), xs:yearMonthDuration("P1Y2M")) returns xs:date("1999-08-30").

The expression op:subtract-yearMonthDuration-from-date(xs:date("2000-02-29Z"), xs:yearMonthDuration("P1Y")) returns xs:date("1999-02-28Z").

The expression op:subtract-yearMonthDuration-from-date(xs:date("2000-10-31-05:00"), xs:yearMonthDuration("P1Y1M")) returns xs:date("1999-09-30-05:00").