Description
The functx:total-months-from-duration function returns the total number of months in $duration. This function is different from the built-in fn:months-from-duration function because the latter will normalize the value and only give you the remainder number of months between 1 and 12. For example, fn:months-from-duration(xs:yearMonthDuration("P18M")) will return 6, while functx:total-months-from-duration(xs:yearMonthDuration("P18M")) will return 18. If $duration is the empty sequence, the empty sequence is returned.
Arguments and Return Type| Name | Type | Description |
$duration |
xs:yearMonthDuration? |
the duration |
| return value |
xs:decimal? |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:total-months-from-duration
( $duration as xs:yearMonthDuration? ) as xs:decimal? {
$duration div xs:yearMonthDuration('P1M')
} ; | | XQuery Syntax for July 2004 - November 2005 (CR): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:total-months-from-duration
( $duration as xdt:yearMonthDuration? ) as xs:decimal? {
$duration div xdt:yearMonthDuration('P1M')
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function total-months-from-duration
( $duration as xdt:yearMonthDuration? ) as xs:decimal? {
$duration div xdt:yearMonthDuration('P1M')
} |
Examples| XQuery Example | Results |
|---|
functx:total-months-from-duration(
xs:yearMonthDuration('P18M'))
|
18
|
functx:total-months-from-duration(
xs:yearMonthDuration('P1Y'))
|
12
|
functx:total-months-from-duration(
xs:yearMonthDuration('P1Y6M'))
|
18
|
See AlsoHistory |
|