XML technologies / XSLT / XSLT and XPath functions / Alphabetical XSLT and XPath reference / day-from-dateTime

(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

fn:day-from-dateTime

Category:

Value extraction from time values, date values and duration

Origin:

XPath 2.0

Return value:

An integer of xs:integer type corresponding to the value of the day component within the timestamp value passed on.

Call/Arguments:

fn:day-from-dateTime($timestampValue)

$timestampValue:

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 the empty sequence.

Purpose of use:

The function returns an integer between 1 and 31 inclusive which corresponds to the value of the day component of the timestamp value passed on of xs:dateTime type. The value is first normalised, which means the timezone factor is integrated into the day component (see examples). This may cause a date jump to the previous or the next day, provided that the normalised daytime portion falls below the value T00:00:00 or exceeds the value T23:59:59 because of the timezone correction factor. In this case, a value other than the possibly expected is outputted (see example 3).

Example 1 - day from timestamp value with negative timzone value:

fn:day-from-dateTime(

xs:dateTime("2007-07-25T12:30:00-05:00")

)

returns the value 25. In this example, the negative timezone value causes no jump of the date. The subtraction causes a normalised daytime component of T17:30:00.

Example 2 - day from timestamp value with negative timezone value:

fn:day-from-dateTime(

xs:dateTime("2007-08-01T04:30:00-05:00")

)

returns 1. In this example, the negative timezone value causes no jump of the date. The subtraction T04:30:00 -(-5:00) causes a normalised daytime component of T09:30:00.

Example 3 - day from timestamp value with positive timezone value:

fn:day-from-dateTime(

xs:dateTime("2007-08-01T04:30:00+05:00")

)

returns the value 31 and not 1, as might be expected. The positive timezone is subtracted during the normalisation: T04:30:00 -(+5:00) and causes a date jump to the previous day – in this example to the 31st of the previous month.

Function definition:

XPath 1.0:

The function is not available.

XPath 2.0:

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

   

 

 

 

back to top