XPath/XQuery divide-yearMonthDuration-by-yearMonthDuration function

Summary

Returns the ratio of two xs:yearMonthDuration values.

Operator Mapping

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

Signature

op:divide-yearMonthDuration-by-yearMonthDuration(
$arg1 as xs:yearMonthDuration,
$arg2 as xs:yearMonthDuration
) as xs:decimal

Rules

The function returns the result of dividing the length in months of $arg1 by the length in months of $arg2, according to the rules of the op:numeric-divide function for integer operands.

For handling of overflow and underflow, see .

Examples

The expression op:divide-yearMonthDuration-by-yearMonthDuration(xs:yearMonthDuration("P3Y4M"), xs:yearMonthDuration("-P1Y4M")) returns -2.5.

The following example demonstrates how to calculate the length of an xs:yearMonthDuration value in months:

The expression op:divide-yearMonthDuration-by-yearMonthDuration(xs:yearMonthDuration("P3Y4M"), xs:yearMonthDuration("P1M")) returns 40.

Notes

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