DateTimeZone.LocalNow

Updated on

DateTimeZone.LocalNow is a Power Query M function that retrieves a datetimezone value set to the current date and time on the system with local timezone information. The function returns a datetimezone value representing the local date and time.

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

Syntax

DateTimeZone.LocalNow() as datetimezone

Description

The syntax for using DateTimeZone.LocalNow is straightforward. You simply need to type DateTimeZone.LocalNow() and the function will return a datetimezone value. This value is set to the current date and time on your system. It’s important to note that the returned value includes timezone information that represents your local timezone.

Unlike the DateTimeZone.FixedLocalNow function, the value returned by DateTimeZone.LocalNow is not fixed. This means that with every call, the returned value will change to reflect the current date and time.

Examples

To better understand how DateTimeZone.LocalNow works, let’s look at an example. When you run the function, it will return an output that looks something like this:

DateTimeZone.LocalNow() 

// When this query was run, the function returned
// #datetimezone( 2023, 7, 23, 12, 56, 24.0738740)
// This is represented as: 2023-07-23T12:56:24.0738740

One key aspect to remember is that DateTimeZone.LocalNow returns the datetimezone value that corresponds to the machine where the query is run. So, if your dataset refreshes in Ireland while you’re located in the Netherlands, the function will return the Irish time.

In case you want a fixed value you can resort to functions like DateTimeZone.FixedUtcNow or DateTimeZone.UtcNow. You can even have these account for daylight savings as explained in this article.

Other functions related to DateTimeZone.LocalNow are:

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

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