DateTimeZone.SwitchZone
Shows the same instant in another time zone: the clock time moves with the offset.
Group: Dates and times. Power Query M has it too: a query that uses it is written as in Power BI.
Syntax
DateTimeZone.SwitchZone(dateTimeZone as nullable datetimezone, timezoneHours as number, optional timezoneMinutes as nullable number) as nullable datetimezone
| Parameter | Type | Description |
|---|---|---|
dateTimeZone | nullable datetimezone | The value to move; null gives null. |
timezoneHours | number | The hours of the new offset. |
timezoneMinutes | nullable number optional | The minutes of the new offset. |
Returns
nullable datetimezone. The same instant with the new offset.
Remarks
- The instant does not change, only how it is written: 14:30 at +01:00 is 08:30 at -05:00. To relabel a clock time without moving it, remove the zone and add another.
Examples
An Oslo order seen from New York
DateTimeZone.SwitchZone(#datetimezone(2024, 3, 15, 14, 30, 0, 1, 0), -5)
#datetimezone(2024, 3, 15, 8, 30, 0, -5, 0)
Seen from India
DateTimeZone.SwitchZone(#datetimezone(2024, 3, 15, 14, 30, 0, 1, 0), 5, 30)
#datetimezone(2024, 3, 15, 19, 0, 0, 5, 30)
Related functions
DateTimeZone.ToUtc, DateTime.AddZone, DateTimeZone.RemoveZone.