DATETIMEFORMAT ER function

The DATETIMEFORMAT function returns a String value that presents a given date/time value as text in the specified format and in an optionally specified culture. For information about the supported formats, see standard and custom.

Syntax 1

DATETIMEFORMAT (datetime, format)

Syntax 2

DATETIMEFORMAT (datetime, format, culture)

Arguments

datetime: DateTime

A date/time value that represents the date and time to format.

format: String

The format of the output string. For information about the supported formats, see standard and custom.

Note

The format string is case-sensitive when you use either a standard format or a custom format. For example, the standard "d" format specifier returns the date by using the short date pattern, whereas the standard "D" format specifier returns the date by using the long date pattern. Additionally, the custom "M" format specifier returns the month from 1 through 12, whereas the custom "m" format specifier returns the minute from 0 through 59.

culture: String

The culture to use for formatting. For information about the supported cultures, see culture.

Return values

String

The resulting string value.

Usage notes

If the culture isn't defined as an argument of the called function, the value of culture is defined by the calling context. For example, if the DATETIMEFORMAT function is called by using syntax 1 in an Electronic reporting (ER) format for a FILE element that is configured to use the German culture, the conversion will be done by using the German culture. The default culture value is EN-US.

When the DATETIMEFORMAT function converts a given date/time value, it considers the time zone setting of the application user who is running the ER format that the function is called in the context of.

Example 1

DATETIMEFORMAT (NOW(), "dd-MM-yyyy") returns the current application server date/time value, December 24, 2015, as "24-12-2015", based on the specified custom format.

Example 2

DATETIMEFORMAT (SESSIONNOW(), "d", "DE") returns the current application session date/time value, December 24, 2015, as "24.12.2015", based on the selected German culture and the specified format.

Example 3

DATETIMEFORMAT (DATETIMEVALUE( "2019-11-12T09:00:00.0000000-07:00", "O"), "O") returns the string value 2019-11-12T08:00:00.0000000-08:00 when the function is called during a process that was initiated by an application user who has the time zone value (GMT-08:00) Pacific Time (US & Canada) in the Language and country/region preferences section.

Additional resources

Date and time functions