OpenBI Docs Buy

DateTime.AddZone

Gives a datetime an offset from UTC, turning it into a datetimezone with the same clock time.

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

Syntax

DateTime.AddZone(dateTime as nullable datetime, timezoneHours as number, optional timezoneMinutes as nullable number) as nullable datetimezone
ParameterTypeDescription
dateTimenullable datetimeThe datetime; null gives null.
timezoneHoursnumberThe hours of the offset: 1 for Oslo in winter, 2 in summer.
timezoneMinutesnullable number
optional
The minutes of the offset, for zones such as +05:30.

Returns

nullable datetimezone. The same clock time, now with an offset.

Remarks

  • The clock time is not changed: the offset only says which zone it was read in. To move a moment to another zone, use DateTimeZone.SwitchZone afterwards.

Examples

A till's local time, recorded in Oslo in winter

DateTime.AddZone(#datetime(2024, 3, 15, 14, 30, 0), 1)
#datetimezone(2024, 3, 15, 14, 30, 0, 1, 0)

An offset with minutes

DateTime.AddZone(#datetime(2024, 3, 15, 9, 0, 0), 5, 30)
#datetimezone(2024, 3, 15, 9, 0, 0, 5, 30)

DateTimeZone.RemoveZone, DateTimeZone.SwitchZone, #datetimezone.

Last updated · OpenBI Studio 0.3.79