Power Query DateTimeZone.FixedLocalNow Function Explained
In this article
The DateTimeZone.FixedLocalNow function in Power Query returns the current local date and time as a datetimezone value, with the system's local time zone applied. It is useful when you need to capture a timestamp that reflects the user's local clock and time zone at the moment of query execution, especially in reports or data models where local context matters more than UTC. No special setup is required beyond having Power Query enabled in Excel or Power BI.
What You'll Need
- Microsoft Excel 2016 or later, or Microsoft Power BI Desktop
- Power Query enabled (default in modern versions)
- A data source or blank query to write the function into
- System clock set to the correct local time and time zone
Step-by-Step
- Open Excel or Power BI Desktop and load or create a new query. In Excel, go to the Data tab and select Get Data > From Other Sources > Blank Query. In Power BI, select Get Data > Blank Query.
- Once the Power Query Editor opens, click on the Advanced Editor button in the Home tab. This opens a text input box where you can write or paste M code.
- Delete any default code in the editor and type:
DateTimeZone.FixedLocalNow(). Ensure the parentheses are included and the function name is spelled exactly as shown, including capitalization. - Click Done to close the Advanced Editor. Power Query will execute the function and display the current local date and time as a datetimezone value in the preview pane, such as
2024-04-15T10:32:15-07:00. - To use this value in your data model, right-click on the column header in the query preview and select Rename. Give it a meaningful name like
LogTimestamporLocalExecutionTime. - To convert this datetimezone value into a plain date or time for reporting, use functions like
DateTimeZone.ToDateTime()to strip the time zone offset orDateTimeZone.ToLocal()to normalize it to local time if needed. - Click Close & Load to load the result into your worksheet or data model. The timestamp will be fixed at the moment the query refreshed and will not change during the session unless refreshed again.
- To verify the result is correct, compare the output to your system’s clock. Open the Windows Clock app or macOS Menu Bar clock and confirm the date, time, and time zone offset match.
- If you plan to use this function in multiple queries, save the query as a reusable function. In the Power Query Editor, go to the View tab and enable the Formula Bar. Then, create a new blank query, open the Advanced Editor, and define it as
let Source = DateTimeZone.FixedLocalNow() in Source, then rename the query toGetLocalNow. You can then reference it in other queries usingGetLocalNow().
Common Mistakes
- Typing
DateTimeZone.FixedLocalNowwithout parentheses — this will cause a syntax error because it’s a function call, not a property. - Confusing it with
DateTimeZone.Now()— the latter returns UTC-based time with the local offset appended, whileFixedLocalNow()directly reflects the system’s local clock without attempting to normalize from UTC. - Expecting the value to update dynamically in Excel cells — it only refreshes when the query is manually refreshed or the workbook is reopened after saving.
- Assuming it works the same in all time zones — the function respects the system’s time zone setting, so if the system clock is incorrect or set to the wrong time zone, the result will be wrong.
- Trying to use it in calculated columns in Power BI tables — it is not allowed in calculated columns because it’s non-deterministic and refresh-dependent. Use it only in query sources or as a parameter.
Tips
- Use
DateTimeZone.FixedLocalNow()for audit logs, data extraction timestamps, or user-specific reporting where local context is required — for example, showing when a report was generated for a user in New York versus Los Angeles. - Combine it with
Date.From()orTime.From()if you only need the date or time portion without the time zone offset. - Use
DateTimeZone.SwitchZone()if you need to convert the result to a different time zone for global reporting. - Always test the function on a device with known time zone settings before deploying to team environments — time zone misconfigurations are the most common cause of incorrect results.
- When sharing workbooks or reports, ensure all users have their system clocks synchronized with internet time services to avoid discrepancies in timestamps across users.
- For automated refreshes in Power BI Service, the function will use the time zone of the gateway machine (if used) or the user’s local time zone during manual refresh — be aware of this if your audience spans multiple regions.
Troubleshooting
- If the function returns an error like
Expression.Error: The name 'DateTimeZone.FixedLocalNow' wasn't recognized, check your Power Query version. This function is available from Excel 2016 and Power BI Desktop versions released after mid-2017. Update your application if needed. - If the timestamp doesn’t match your local clock, verify your operating system’s date, time, and time zone settings. Go to Windows Settings > Time & Language > Date & Time, or macOS System Preferences > Date & Time, and ensure automatic time zone and time sync are enabled.
- If you see an unexpected offset like
+00:00, your system may be set to UTC. Change the time zone to your actual location. - If Power Query doesn’t refresh the value when expected, manually click Refresh All in Excel or click Refresh in Power BI. The function does not auto-refresh like a live data source.
- If you're working in a shared Power BI workspace and the timestamp appears wrong for other users, remember that each user’s local time zone affects the result during their refresh — this is intentional behavior, not a bug.
- If you accidentally used the function in a calculated column and got an error, move the logic to a new query or use a parameter to store the value before importing into the model.