Skip to Content
XQuery
book

XQuery

by Priscilla Walmsley
March 2007
Intermediate to advanced content levelIntermediate to advanced
512 pages
21h 15m
English
O'Reilly Media, Inc.
Content preview from XQuery

xs:duration

The primitive type xs:duration represents a duration of time. It allows you to specify a number of years (Y), months (M), days (D), hours (H), minutes (M), and seconds (S). The lexical representation of xs:duration is PnYnMnDTnHnMnS, where an uppercase P starts the expression, n indicates the quantity of each component, and an uppercase letter T separates the day and time components. For example, the value P3YT5H represents a period of three years and five hours.

The following rules apply to xs:duration values:

  • A minus sign may appear at the beginning of the value (before the P) to indicate a negative duration.

  • You can omit components whose quantity is zero, but at least one component is required.

  • If no time components (hours, minutes, seconds) are specified, the T cannot appear.

  • The numbers must be integers, except for the number of seconds, which can include a decimal point. XQuery implementations are required to support up to three fractional digits in the number of seconds, but may support more.

  • If a decimal point appears in the number of seconds, there must be at least one digit after the decimal point.

Table B-9 lists some values of the xs:duration type. For more information on working with durations, see Chapter 19.

Table B-9. Values of the xs:duration type

Values

Explanation

Valid

 
P3Y5M8DT9H25M20S

3 years, 5 months, 8 days, 9 hours, 25 minutes, 20 seconds

P2DT3H

2 day, 3 hours

P25M

25 months (the number of months may be more than 12)

PT25M

25 minutes ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

XQuery, 2nd Edition

XQuery, 2nd Edition

Priscilla Walmsley
XPath and XPointer

XPath and XPointer

John Simpson
XQuery Kick Start

XQuery Kick Start

James McGovern, Per Bothner, Kurt Cagle, James Linn, Vaidyanathan Nagarajan
Learning XSLT

Learning XSLT

Michael Fitzgerald

Publisher Resources

ISBN: 0596006349Supplemental ContentErrata