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.
Related articles
Learn more about DateTime.LocalNow in the following articles:
- How to Create Today’s Date in Power Query M
Learn how to create the current date in Power Query! You can use Today’s date to make your queries dynamic and perform checks on timeliness. » Read more - Last Refresh DateTime in Power BI (w/ Daylight Savings)
Create a last refresh DateTime in Power BI that respects daylight savings and returns the correct results regardless of the location. Fix location issues! » Read more - Create Date Table or Calendar in Power Query M
Learn how to create a dynamic calendar table in Power Query’s M language. Build your custom columns and claim your free Date Table Script. » Read more - Timing M Query Execution In Power Query And Power BI (Revisited)
This article shows how you can retrieve the execution time of a query in Power Query. » Read more
Related functions
Other functions related to DateTime.LocalNow are:
2023-2024 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy