home contribute faq download

FunctX XQuery Functions

fn:minutes-from-duration

The number of minutes in a duration

Google
Webxqueryfunctions.com

Description

The fn:minutes-from-duration function calculates the minutes component of a normalized xs:duration value, as an integer between -59 and 59 inclusive. This is not necessarily the same as the integer that appears before the M in the value. For example, if the duration is PT1M90S, the function returns 2 rather than 1. This is because 90 seconds is equal to 1.5 minutes, and the normalized value is therefore PT2M30S. Likewise, if the duration is PT90M, the result is 30, because the normalized value is PT1H30M.

For a function that returns the total number of minutes as a decimal number, see functx:total-minutes-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
minutes-from-duration(
  xs:dayTimeDuration('PT30M'))
30
minutes-from-duration(
  xs:dayTimeDuration('-PT90M'))
-30
minutes-from-duration(
  xs:dayTimeDuration('PT1M90S'))
2
minutes-from-duration(
  xs:dayTimeDuration('PT3H'))
0
minutes-from-duration(
  xs:dayTimeDuration('PT60M'))
0

See Also

functx:total-minutes-from-durationThe total number of minutes 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