home contribute faq download

FunctX XQuery Functions

fn:days-from-duration

The number of days in a duration

Google
Webxqueryfunctions.com

Description

The fn:days-from-duration function calculates the total number of whole days in a normalized xs:duration value. This is not necessarily the same as the integer that appears before the D in the value. For example, if the duration is P1DT36H, the function returns 2 rather than 1. This is because 36 hours is equal to 1.5 days, and the normalized value is therefore P2DT12H.

This function does not round the number of days; if the duration is 2 days and 23 hours, it returns the integer 2.

For a function that returns the total number of days as a decimal number, see functx:total-days-from-duration.

This description is © Copyright 2007, Priscilla Walmsley. It is excerpted from the book XQuery by Priscilla Walmsley, O'Reilly, 2007. For a complete explanation of this function, please refer to Appendix A of the book.

Arguments and Return Type

NameType
$arg xs:duration?
return value xs:integer?

Examples

XQuery ExampleResults
days-from-duration(
   xs:dayTimeDuration('P5D'))
5
days-from-duration(
   xs:dayTimeDuration('-PT24H'))
-1
days-from-duration(
   xs:dayTimeDuration('PT23H'))
0
days-from-duration(
   xs:dayTimeDuration('P1DT36H'))
2
days-from-duration(
   xs:dayTimeDuration('PT1440M'))
1

See Also

functx:total-days-from-durationThe total number of days in a dayTimeDuration

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26W3C, XQuery 1.0 and XPath 2.0 Functions and Operators, http://www.w3.org/TR/xpath-functions/
Datypic XQuery Services

Recommended Reading:

XQuery