Converts a value of type xs:dateTime to a string. The string representation of date and time is formatted according to the value of the format argument.
Built-in, C++, C#, Java, XSLT 2.0, XSLT 3.0.
The xs:dateTime value to be formatted.
A format string identifying the way in which value is to be formatted. See "Remarks" below.
Optional argument. When supplied, the name of the month and the day of the week are returned in a specific language. Valid values:
|Note:||If the function’s output (result) is connected to an item of type other than string, the formatting may be lost as the value is cast to the target type. To disable this automatic cast, clear the Cast target values to target types check box in the Component Settings of the target component.|
The format argument consists of a string containing so-called variable markers enclosed in square brackets, for example [Y]/[M]/[D]. Characters outside the square brackets are literal characters. If square brackets are needed as literal characters in the result, then they should be doubled.
Each variable marker consists of a component specifier identifying which component of the date or time is to be displayed, an optional formatting modifier, another optional presentation modifier and an optional width modifier, preceded by a comma if it is present.
format := (literal | argument)*
argument := [component(format)?(presentation)?(width)?]
width := , min-width ("-" max-width)?
The components are as follows:
year (absolute value)
four digits (2010)
month of the year
day of month
day of year
day of week
name of the day (language dependent)
week of the year
week of month
hour (24 hours)
hour (12 hour)
A.M. or P.M.
alphabetic (language dependent)
minutes in hour
seconds in minute
numeric, one decimal place
timezone as a time offset from UTC
timezone as a time offset using GMT
The formatting modifier can be one of the following:
Decimal numeric format with no leading zeros
1, 2, 3
Decimal format, two digits
01, 02, 03
Name of component, upper case1
Name of component, lower case1
Name of component, title case1
1. The N, n, and Nn modifiers are supported by the following components only: M, d, D.
The width modifier, if necessary, is introduced by a comma, followed by a digit that expresses the minimum width. Optionally, you can add a dash followed by another digit that expresses the maximum width. For example:
•[D,2] is the day of the month, with leading zeros (two digits).
•[MNn,3-3] is the name of the month, written as three characters, e.g. Jan, Feb, Mar, and so on.
The table below illustrates some examples of formatting xs:dateTime values with the help of the format-dateTime function. The "Value" column specifies the value supplied to the value argument. The "Format" column specifies the value of the format argument. The "Result" column illustrates what is returned by the function.
[Y] [MNn] [D01] [F,3-3] [d] [H]:[m]:[s].[f]
2010 June 02 Wed 153 8:02:12.054
[Y] [MNn] [D01] [F,3-3] [d] [H]:[m]:[s].[f] [z]
2010 June 02 Wed 153 8:02:12.054 GMT+02:00
[Y] [MNn] [D1] [F] [H]:[m]:[s].[f] [Z]
2010 June 2 Wednesday 8:02:12.054 +02:00
[Y] [MNn] [D] [F,3-3] [H01]:[m]:[s]
2010 June 2 Wed 08:02:12