Skip to Content
XQuery
book

XQuery

by Priscilla Walmsley
March 2007
Intermediate 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.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

XQuery, 2nd Edition

XQuery, 2nd Edition

Priscilla Walmsley
XPath and XPointer

XPath and XPointer

John Simpson
XSLT

XSLT

Doug Tidwell

Publisher Resources

ISBN: 0596006349Errata