# op:subtract-yearMonthDuration-from-date

Subtracts the time duration specified by $yearMonthDuration-var from the date specified by $date-var.

### Signatures

op:subtract-yearMonthDuration-from-date(xs:date $date-var, xf:yearMonthDuration $yearMonthDuration-var) —> xs:date

### Arguments

Data Type | Argument | Description
--- | --- | ---
xs:date | $date-var | Contains a representation of the date.
xf:yearMonthDuration | $yearMonthDuration-var | Contains a time duration which can contain years and months.

### Returns

Returns the date value of subtracting the time duration specified by $yearMonthDuration-var from the date specified by $date-var.

### Examples

#### Subtracting a Positive yearMonthDuration

The following example query subtracts a positive yearMonthDuration value equal to 1 year and 1 month from a date value equal to the date: February 2, 2003 as shown in the following query:

    <positive>{
    	op:subtract-yearMonthDuration-from-date(xs:date("2003-02-02"), xf:yearMonthDuration("P1Y1M"))
    }</positive>

The resulting date value equal to the date: January 2, 2002 is returned as shown in the following result:

    <positive>2002-01-02</positive>

#### Subtracting a Negative yearMonthDuration

The following example query subtracts a negative yearMonthDuration value equal to 1 year and 1 month from a date value equal to the date: January 2, 2003 as shown in the following query:

    <negative>{
    	op:subtract-yearMonthDuration-from-date(xs:date("2003-01-02"), xf:yearMonthDuration("-P1Y1M"))
    }</negative>

The resulting date value equal to the date: February 2, 2004 is returned as shown in the following result:

    <negative>2004-02-02</negative>

Related Topics

W3C subtract-yearMonthDuration-from-date operator description.

W3C yearMonthDuration description.

xf:yearMonthDuration constructor description.

W3C date data type description

xs:date constructor description.