XPath/XQuery divide-dayTimeDuration-by-dayTimeDuration function


Returns the ratio of two xs:dayTimeDuration values, as a decimal number.

Operator Mapping

Defines the semantics of the "div" operator when applied to two xs:dayTimeDuration values.


$arg1 as xs:dayTimeDuration,
$arg2 as xs:dayTimeDuration
) as xs:decimal


The function returns the result of dividing the value of $arg1 by $arg2. The result is the xs:dayTimeDuration whose length in seconds is equal to the length in seconds of $arg1 divided by the length in seconds of $arg2. The calculation is performed by applying op:numeric-divide to the two xs:decimal operands.

For handling of overflow and underflow, see .


The expression fn:round-half-to-even( op:divide-dayTimeDuration-by-dayTimeDuration( xs:dayTimeDuration("P2DT53M11S"), xs:dayTimeDuration("P1DT10H")), 4) returns 1.4378.

This examples shows how to determine the number of seconds in a duration.

The expression op:divide-dayTimeDuration-by-dayTimeDuration(xs:dayTimeDuration("P2DT53M11S"), xs:dayTimeDuration("PT1S")) returns 175991.0.


Either operand (and therefore the result) may be negative.