DateTimeZone.UtcNow

Updated on

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.

Learn more about DateTimeZone.UtcNow in the following articles:

Other functions related to DateTimeZone.UtcNow are:

BI Gorilla Youtube Channel

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