TimeZone.Current

TimeZone.Current is a Dynamic Value in the Power Query M language that returns the name of the current time zone for the application. It is used when you need to adjust or convert time data according to the application’s current time zone. It can be crucial for applications dealing with time-sensitive data, scheduling, or when operating across multiple time zones.

Examples

Delving into the functionality of TimeZone.Current, the most elementary use case involves retrieving the identifier of the time zone configured on your local machine. This is achieved simply by calling TimeZone.Current without any additional parentheses.

TimeZone.Current // Output varies based on your local settings, e.g. "W. Europe Standard Time"

This function yields a precise string representation of your system’s time zone, such as “W. Europe Standard Time”. Do note, however, the output of this function will fluctuate, adjusting to the settings of the local machine executing the function.

A more complex utilization of TimeZone.Current can be seen in situations where you need to keep a track of which machine, or rather which time zone, has refreshed a dataset. The TimeZone.Current function can dynamically tag your datasets with the relevant time zone information during the refresh operation.

TimeZone.Current can also come in handy when dealing with translation tables or scenarios where you want to dynamically modify a value based on the user’s time zone. For instance, you could have an application that adjusts a DateTime value depending on whether the user is in the “W. Europe Standard Time” zone or not.

Consider the following example where we adjust the timezone offset based on the user’s time zone:

if TimeZone.Current = "W. Europe Standard Time" 
   then DateTime.AddZone( #datetime( 2010, 12, 31, 11, 56, 02 ), 2 )
   else DateTime.AddZone( #datetime( 2010, 12, 31, 11, 56, 02 ), 0 )

Here, if the user’s time zone is “W. Europe Standard Time”, the function DateTime.AddZone adds an offset of 2 hours to the input DateTime value. For users in other time zones, no offset is added. This can be used to ensure the displayed DateTime value is relevant and accurately represents the user’s local time.

Related dynamic values

Other related dynamic values are:

BI Gorilla Blog

Last update: August 17, 2023 | Contribute » | Contributors: Rick de Groot
Microsoft documentation: https://learn.microsoft.com/en-us/powerquery-m/timezone-current
© 2023 BI Gorilla. All rights reserved. Content derived from Microsoft documentation is property of Microsoft Corp.