# op:subtract-dayTimeDuration-from-dateTime

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

### Signatures

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

### Arguments

Data Type | Argument | Description
--- | --- | ---
xs:dateTime | $dateTime-var | Contains a representation of the date and time.
xf:dayTimeDuration | $dayTimeDuration-var | Contains a time duration that can contain days, hours, minutes, and seconds.

### Returns

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

### Examples

#### Subtracting a Positive dayTimeDuration

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

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

The resulting dateTime value equal to the date: January 1, 2003 and time: 1:00 AM is returned as shown in the following result:

    <positive>2003-01-01T01:00:00</positive>

#### Subtracting a Negative dayTimeDuration

The following example query subtracts a negative dayTimeDuration value equal to 1 day and 1 minute 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-dayTimeDuration-from-dateTime(xs:dateTime("2003-01-02T01:01:00"), xf:dayTimeDuration("-P1DT1M"))
    }</negative>

The resulting dateTime value equal to the date: January 3, 2003 and time: 1:02 AM is returned as shown in the following result:

    <negative>2003-01-03T01:02:00</negative>

Related Topics

W3C subtract-dayTimeDuration-from-dateTime operator description.

W3C dayTimeDuration description.

xf:dayTimeDuration constructor description.

W3C dateTime data type description

xs:dateTime constructor description.