
fn:seconds-from-duration function
The fn:seconds-from-durationfunction returns the seconds component of a duration.
Syntax
>>-fn:seconds-from-duration(duration-value)--------------------><
- duration-value
- The duration value from which the seconds component is to be extracted.
duration-value is an empty sequence, or is a value that has one of the following types: xs:dayTimeDuration, xs:duration, or xs:yearMonthDuration.
Returned value
The return value depends on the type of duration-value:
- If duration-value is of type xs:dayTimeDuration, or is of type xs:duration, the returned value is of type xs:decimal, and is a value greater than -60 and less than 60. The value is the seconds and fractional seconds component of duration-value cast as xs:dayTimeDuration. The value is negative if duration-value is negative.
- If duration-value is of type xs:yearMonthDuration, the returned value is of type xs:integer and is 0.
- If duration-value is an empty sequence, the returned value is an empty sequence.
The seconds and fractional seconds component of duration-value cast as xs:dayTimeDuration is computed as (S mod 60). The value S is the total number of seconds and fractional seconds of duration-value cast as xs:dayTimeDuration to remove the years and months components.
Example
The following function returns the seconds component of the duration 150.5 seconds.
fn:seconds-from-duration(xs:dayTimeDuration("PT150.5S"))
The returned value is 30.5. When calculating the total number of seconds in the duration, 150.5 seconds is converted to 2 minutes and 30.5 seconds. The duration is equal to PT2M30.5S which has a seconds component of 30.5 seconds.

