Divides $yearMonthDuration-var by $decimal-var.
op:divide-yearMonthDuration(xf:yearMonthDuration $yearMonthDuration-var, xs:decimal $decimal-var) —> xf:yearMonthDuration
Returns the yearMonthDuration value of dividing $yearMonthDuration-var by $decimal-var. The return value is rounded up to the nearest year and month as shown in following example.
Dividing the 1 year value of $yearMonthDuration-var by 2.0 results in 6 months. Dividing the 1 month value of $yearMonthDuration-var by 2.0 results in .5 months which is rounded up to 1 month. Adding 6 months to 1 month results in a yearMonthDuration of 7 months as shown in the following example query:
let $yearMonthDuration-var := xf:yearMonthDuration("P1Y1M") return let $decimal-var := 2 return let $mydur := op:divide-yearMonthDuration($yearMonthDuration-var, $decimal-var) return <result> <years>{xf:get-years-from-yearMonthDuration($mydur)}</years> <months>{xf:get-months-from-yearMonthDuration($mydur)}</months> </result>
The preceding query generates the following result:
<result> <years>0</years> <months>7</months> </result>
Dividing a 1 month yearMonthDuration by 2.04 results in 0.4901... months which is rounded down to zero months as shown in the following example query:
let $yearMonthDuration-var := xf:yearMonthDuration("P1M") return let $decimal-var := 2.04 return let $mydur := op:divide-yearMonthDuration($yearMonthDuration-var, $decimal-var) return <result> <years>{xf:get-years-from-yearMonthDuration($mydur)}</years> <months>{xf:get-months-from-yearMonthDuration($mydur)}</months> </result>
The preceding query generates the following result:
<result> <years>0</years> <months>0</months> </result>
W3C divide-yearMonthDuration operator description.
W3C yearMonthDuration description.
xf:yearMonthDuration constructor description.