Subtracts the time duration specified by $yearMonthDuration-var from the date and time specified by $dateTime-var.
op:subtract-yearMonthDuration-from-dateTime(xs:dateTime $dateTime-var, xf:yearMonthDuration $yearMonthDuration-var) —> xs:dateTime
Contains a time duration which can contain years and months. |
Returns the dateTime value of subtracting the time duration specified by $yearMonthDuration-var from the date and time specified by $dateTime-var.
The following example query subtracts a positive yearMonthDuration value equal to 1 year and 1 month from a dateTime value equal to the date: February 2, 2003 and time: 1:01 AM as shown in the following query:
<positive>{ op:subtract-yearMonthDuration-from-dateTime(xs:dateTime("2003-02-02T01:01:00"), xf:yearMonthDuration("P1Y1M")) }</positive>
The resulting dateTime value equal to the date: January 2, 2002 and time: 1:01 AM is returned as shown in the following result:
<positive>2002-01-02T01:01:00</positive>
The following example query subtracts a negative yearMonthDuration value equal to 1 year and 1 month from a dateTime value equal to the date: January 2, 2003 and time: 1:01 AM as shown in the following query:
<negative>{ op:subtract-yearMonthDuration-from-dateTime(xs:dateTime("2003-01-02T01:01:00"), xf:yearMonthDuration("-P1Y1M")) }</negative>
The resulting dateTime value equal to the date: February 2, 2004 and time: 1:01 AM is returned as shown in the following result:
<negative>2004-02-02T01:01:00</negative>
W3C subtract-yearMonthDuration-from-dateTime operator description.
W3C yearMonthDuration description.
xf:yearMonthDuration constructor description.
W3C dateTime data type description
xs:dateTime constructor description.