OpenBI Docs Buy

DateTimeZone.ToText

Writes a datetimezone as text, offset included, in the culture's form or a format you give.

Group: Dates and times. Power Query M has it too: a query that uses it is written as in Power BI.

Syntax

DateTimeZone.ToText(dateTimeZone as nullable datetimezone, optional options as any, optional culture as nullable text) as nullable text
ParameterTypeDescription
dateTimeZonenullable datetimezoneThe value to write; null gives null.
optionsany
optional
A record [Format = ..., Culture = ...], both fields optional; or, as older queries do, a format as text.
culturenullable text
optional
A culture's name, when options is a format given as text.

Returns

nullable text. The value as text.

Remarks

  • Text follows the culture: the one given, else the query's (Culture.Current), which is the model's Locale for import, else the model's own culture, else en-US. These examples run in en-US unless a culture is given. Left without a format, the culture's date and time are followed by the offset.
  • A format is built from letters: yyyy the year, MM the month as two digits, MMM and MMMM its short and full name, dd the day, ddd and dddd the weekday's short and full name, HH the hour on a 24-hour clock, hh on a 12-hour clock with tt for AM or PM, mm minutes, ss seconds. Text in single quotes is copied as it is. zzz writes the offset as +01:00.

Examples

The culture's form

DateTimeZone.ToText(#datetimezone(2024, 3, 15, 14, 30, 0, 1, 0))
"3/15/2024 2:30:00 PM +01:00"

An ISO timestamp for an API

DateTimeZone.ToText(#datetimezone(2024, 3, 15, 14, 30, 0, 1, 0), [Format = "yyyy-MM-ddTHH:mm:sszzz"])
"2024-03-15T14:30:00+01:00"

In Norwegian

DateTimeZone.ToText(#datetimezone(2024, 3, 15, 14, 30, 0, 1, 0), [Culture = "nb-NO"])
"15.03.2024 14:30:00 +01:00"

DateTimeZone.FromText, DateTime.ToText, DateTimeZone.ZoneHours.

Last updated · OpenBI Studio 0.3.79