op:subtract-dayTimeDuration-from-date

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

Signatures

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

Arguments

Data Type
Argument
Description

xs:date

$date-var

Contains a representation of the date.

xf:dayTimeDuration

$dayTimeDuration-var

Contains a time duration that can contain days, hours, minutes, and seconds.

Returns

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

Examples

Subtracting a Positive dayTimeDuration

The following example query subtracts a positive dayTimeDuration value equal to 1 day and 1 minute from a date value equal to the date: January 2, 2003 as shown in the following query:

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

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

<positive>2003-01-01</positive> 

Subtracting a Negative dayTimeDuration

The following example query subtracts a negative dayTimeDuration value equal to 1 day and 1 minute from a date value equal to the date: January 2, 2003 as shown in the following query:

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

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

<negative>2003-01-03</negative> 

Related Topics

W3C subtract-dayTimeDuration-from-date operator description.

W3C dayTimeDuration description.

xf:dayTimeDuration constructor description.

W3C date data type description

xs:date constructor description.