.. _years-from-duration: =================== years-from-duration =================== The number of years in a duration Description ~~~~~~~~~~~ The fn:years-from-duration function calculates the years component of a normalized xs:duration value. This is not necessarily the same as the integer that appears before the Y in the value. For example, if the duration is P1Y18M, the function returns 2 rather than 1. This is because 18 months is equal to 1.5 years, and the normalized value is therefore P2Y6M. For a function that returns the total number of years as a decimal number, see functx:total-years-from-duration. .. list-table:: :widths: 40 60 :header-rows: 1 * - **Parameters** - **Description** * - arg:numeric() - Examples ~~~~~~~~ .. list-table:: :widths: 50 50 :header-rows: 1 * - **XPath** - **Results** * - years-from-duration(xs:yearMonthDuration('P3Y')) - 3 * - years-from-duration(xs:yearMonthDuration('P3Y11M')) - 3 * - years-from-duration(xs:yearMonthDuration('-P18M')) - -1 * - years-from-duration(xs:yearMonthDuration('P1Y18M')) - 2 * - years-from-duration(xs:yearMonthDuration('P12M')) - 1 See Also ~~~~~~~~ .. toctree:: :titlesonly: :glob: * :ref:`functx_total-years-from-duration`.