DateTime.LocalNow

Updated on

DateTime.LocalNow is a Power Query M function that returns a datetime value set to the current date and time on the system. The function returns the current date and time as a datetime value.

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

Syntax

DateTime.LocalNow() as datetime

Description

Returns a datetime value set to the current date and time on the system. This value will change with successive calls, unlike DateTime.FixedLocalNow, which does not return different values over the course of execution of an expression.

Examples

Let’s see an example of the DateTime.LocalNow function. Here’s the output of this function at the moment it was run:

DateTime.LocalNow() 

// At the time of running this query the function returns
// #datetimezone( 2023, 7, 23, 12, 56, 24.0738740)
// represented by: 2023-07-23T12:56:24.0738740

An important point to note is that the DateTime.LocalNow function gives you the datetime value associated with the system on which the query is executed. This means if your dataset is refreshed in Ireland, but you’re in the Netherlands, the function will yield the time in Ireland.

If you prefer a constant value, you can use functions such as DateTimeZone.FixedUtcNow or DateTimeZone.UtcNow. These functions can also be adjusted to consider daylight savings time, as detailed in this linked article.

Learn more about DateTime.LocalNow in the following articles:

Other functions related to DateTime.LocalNow are:

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