# op:divide-yearMonthDuration

Divides $yearMonthDuration-var by $decimal-var.

### Signatures

op:divide-yearMonthDuration(xf:yearMonthDuration $yearMonthDuration-var, xs:decimal $decimal-var) —> xf:yearMonthDuration

### Arguments

Data Type | Argument | Description
--- | --- | ---
xf:yearMonthDuration | $yearMonthDuration-var | Contains a time duration that can contain years and months.
xs:decimal | $decimal-var | Contains a decimal value, for example: 1.1.

### Returns

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.

### Examples

#### Round Up

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>

#### Not Enough to Round Up

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>

Related Topics

W3C divide-yearMonthDuration operator description.

W3C yearMonthDuration description.

xf:yearMonthDuration constructor description.