DateTimeZone.ToLocal

Updated on

DateTimeZone.ToLocal is a Power Query M function that changes the timezone information of a datetimezone value to the local timezone. The function returns a datetimezone value with the local timezone information added or updated.

Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365

Syntax

DateTimeZone.ToLocal( dateTimeZone as nullable datetimezone ) as nullable datetimezone

Description

The DateTimeZone.ToLocal function alters the timezone information of the datetimezone value dateTimeZone to match the local timezone information. If dateTimeZone does not have a timezone component, the local timezone information is added.

Examples

To better understand how DateTimeZone.ToLocal works, let’s look at an example. This function can change the timezone information for a datetimezone value.

For instance, the following value uses a timezone from +7 hours. If your local time is Dutch (which is +1 in summertime), you can transform this value into the local time as follows:

// Output: #datetimezone(2023, 12, 31, 05, 56, 2, 1, 0)

DateTimeZone.ToLocal( #datetimezone( 2023, 12, 31, 11, 56, 02, 7, 0 ) )

This operation subtracts 6 hours from the presented datetime value to shift from UTC + 7 to GMT + 1.

In conclusion, DateTimeZone.ToLocal allows you to modify the timezone information of a datetimezone value to match the local timezone. It’s especially useful when dealing with data across different timezones.

Other functions related to DateTimeZone.ToLocal are:

Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/datetimezone-tolocal

2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy