op:subtract-yearMonthDurations

Subtracts the value of $yearMonthDuration-var2 from $yearMonthDuration-var1.

Signatures

op:subtract-yearMonthDurations(xf:yearMonthDuration $yearMonthDuration-var1, xf:yearMonthDuration $yearMonthDuration-var2) —> xf:yearMonthDuration

Arguments

Data Type
Argument
Description

xf:yearMonthDuration

$yearMonthDuration-var1

Contains a time duration that can contain years and months.

xf:yearMonthDuration

$yearMonthDuration-var2

Contains a time duration that can contain years and months.

Returns

Returns the yearMonthDuration value of subtracting $yearMonthDuration-var2 from $yearMonthDuration-var1.

Examples

Positive

The following example query subtracts a yearMonthDuration value equal to 1 year and 1 month from a yearMonthDuration value equal to 3 years and 3 months as shown in the following query:

<positive>{
		op:subtract-yearMonthDurations(xf:yearMonthDuration("P3Y3M"), xf:yearMonthDuration("P1Y1M"))
}</positive> 

The resulting positive yearMonthDuration value of 2 years and 2 months is returned as shown in the following result:

<positive>P2Y2M</positive> 

Negative

The following example query subtracts a yearMonthDuration value equal to 3 years and 3 months from a yearMonthDuration value equal to 1 year and 1 month as shown in the following query:

<negative>{
		op:subtract-yearMonthDurations(xf:yearMonthDuration("P1Y1M"), xf:yearMonthDuration("P3Y3M"))
}</negative> 

The resulting negative yearMonthDuration value of 2 years and 2 months is returned as shown in the following result:

<negative>-P2Y2M</negative> 

Related Topics

W3C subtract-yearMonthDurations operator description.

W3C yearMonthDuration description.

xf:yearMonthDuration constructor description.