DateTimeZone.UtcNow is a Power Query M function that provides the current date and time in UTC (the GMT timezone). The function returns a datetimezone value representing the current UTC date and time.
Compatible with: Power BI Service Power BI Desktop Excel Microsoft 365
Syntax
DateTimeZone.UtcNow() as datetimezone
Description
The DateTimeZone.UtcNow function returns the current date and time in UTC (the GMT timezone).
Examples
To get a clearer picture of how DateTimeZone.UtcNow operates, let’s delve into an example. When you execute the function, it will return the current date and time in UTC. Here’s what the output might look like:
DateTimeZone.UtcNow()
// When this query was run, the function returned
// #datetimezone( 2023, 7, 23, 12, 56, 24.0738740, 0, 0)
// This is represented as: 2023-07-23T12:56:24.0738740+00:00
An important thing to note is that DateTimeZone.UtcNow always returns the UTC time, irrespective of where you run it. This consistent behavior allows you to customize the function to always return a specific datetimezone value. For example, you can use the following formula to always get the current UTC+2 time, regardless of where the data refresh happens:
DateTimeZone.SwitchZone( DateTimeZone.UtcNow(), 2 )
// When this query was run, the function returned
// #datetimezone( 2023, 7, 23, 12, 56, 24.0738740, 2, 0)
// This is represented as: 2023-07-23T12:22:10.3589497+02:00
This example effectively transforms UTC into a fixed timezone. However, if you need to dynamically account for daylight savings, you might want to explore other resources. You can check out this detailed article on that topic for more information.
In summary, DateTimeZone.UtcNow is useful, whether you want to track the current time in UTC or a specific timezone.
Related articles
Learn more about DateTimeZone.UtcNow 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
Related functions
Other functions related to DateTimeZone.UtcNow are:
2023-2026 © BI Gorilla. All rights are reserved. Information from Microsoft docs is property of Microsoft Corp. | Privacy Policy