XSLT and XPath function reference in alphabetical order

(Excerpt from “XSLT 2.0 & XPath 2.0” by Frank Bongers, chapter 5, translated from German)

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z



Value extraction from time values, date values and duration


XPath 2.0

Return value:

An integer of xs:integer type which corresponds to the value of the hours component within the timestamp value passed on.




Optional. A timestamp value of xs:dateTime type which may include a timezone indication. If the empty sequence is passed on, the function also returns an empty output sequence.

Purpose of use:

The function returns an integer between inclusive 0 to 23 which corresponds to the value of the hours component of the timestamp value passed on of xs:dateTime type. The value is normalised beforehand, which means the timezone factor is included (see examples). This may cause a date jump to the previous day or to the next day, provided that the normalised daytime portion does not fall below the value T00:00:00 or does not exceed the value T23:59:59 because of the timezone correction factor. In this case, another value is outputted as the possibly expected (see example 2).

Example 1 - hours from timestamp value, version 1:




Results in: 15.

The inclusion of the timezone correction factor results in a hour value of 15. Here, no date jump occurs.

Example 2 - hours from timestamp value, version 2:




Results in: 2.

In this case, during the normalisation the correction factor of the timezone causes a date jump to the next day T02:30:00.

Example 3 - hours from timestamp value, version 3:




Results in: 17.

When having an assumed implicit timezone factor of -5:00, in this example the value 17 becomes the result by subtracting the appropriate correction factor of -5:00 from 12 - (-5:00).

Function definition:

XPath 1.0:

The function is not available.

XPath 2.0:

fn:hours-from-dateTime($arg as xs:dateTime?) as xs:integer?


<< back next >>




Copyright © Galileo Press, Bonn 2008
Printing of the online version is permitted exclusively for private use. Otherwise this chapter from the book "XSLT 2.0 & XPath 2.0" is subject to the same provisions as those applicable for the hardcover edition: The work including all its components is protected by copyright. All rights reserved, including reproduction, translation, microfilming as well as storage and processing in electronic systems.

Galileo Press, Rheinwerkallee 4, 53227 Bonn, Germany