OpenBI Docs Buy

DateTimeZone.From

Turns a value into a datetimezone; text with an offset is read with it.

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

Syntax

DateTimeZone.From(value as any, optional culture as nullable text) as nullable datetimezone
ParameterTypeDescription
valueanyA datetimezone, text, date, datetime, time or number; null gives null.
culturenullable text
optional
A culture's name for reading text; left out, the query's culture.

Returns

nullable datetimezone. The datetimezone.

Remarks

  • Text is read as DateTimeZone.FromText reads it: write the offset after the time, such as +01:00, or a Z for UTC.
  • A date, datetime or time is taken as the computer's clock time and gets the computer's offset at that moment: +01:00 in Oslo in winter, +02:00 in summer. A number counts days from 30 December 1899 first, as DateTime.From does. The computer's time zone is the one of the computer that runs the query, with its summer time: the studio's on your desk, the server's when a model refreshes there. These examples ran in Oslo (+01:00 in winter, +02:00 in summer).

Examples

A timestamp from a web shop

DateTimeZone.From("2024-03-15T14:30:00+01:00")
#datetimezone(2024, 3, 15, 14, 30, 0, 1, 0)

A UTC timestamp

DateTimeZone.From("2024-03-15T13:30:00Z")
#datetimezone(2024, 3, 15, 13, 30, 0, 0, 0)

A datetime gets the computer's offset

DateTimeZone.From(#datetime(2024, 7, 5, 10, 0, 0))
#datetimezone(2024, 7, 5, 10, 0, 0, 2, 0)

On a computer in Oslo, July is summer time: +02:00.

DateTimeZone.FromText, DateTime.AddZone, DateTime.From, DateTimeZone.ToLocal.

Last updated · OpenBI Studio 0.3.79