op:subtract-times

Computes the time difference between $time-var1 and $time-var2. Subtracts the value of $time-var2 from $time-var1.

If the value of $time-var2 follows in time the value of $time-var1, then the returned value is a negative duration.

If the value of $date-var1 or $date-var2 is the empty sequence, the following error is displayed:

Error occurred while executing XQuery: Error loading the XQuery or XSLT for this method: 
Type error in function subtract-dates invocation: expected type [date@http://www.w3.org/2001/XMLSchema], 
given type empty 

Signatures

op:subtract-times(xs:time $time-var1, xs:time $time-var2) —> xs:dayTimeDuration

Arguments

Data Type
Argument
Description

xs:time

$time-var1

Contains a representation of time.

xs:time

$time-var2

Contains a representation of time.

Returns

Returns the time difference between $time-var1 and $time-var2 as dayTimeDuration value.

Examples

Positive

The following example returns a positive number of minutes because $time-var2 precedes in time $time-var1:

<minutes>{xf:get-minutes-from-dayTimeDuration(op:subtract-times(xf:time("08:01:00"),
xf:time("08:00:00")))}</minutes> 

The preceding query generates the following result:

<minutes>1</minutes> 

Negative

The following example returns a negative number of days because $time-var2 follows in time $time-var1:

<minutes>{xf:get-minutes-from-dayTimeDuration(op:subtract-times(xf:time("08:00:00"),
xf:time("08:01:00")))}</minutes> 

The preceding query generates the following result:

<minutes>-1</minutes> 

Related Topics

W3C subtract-times operator description.

W3C date data type description.

W3C dayTimeDuration operator description.