Starting December 3, join live sessions with database experts and the Microsoft product team to learn just how easy it is to get started
Learn moreGet certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now
Is DateTimeZone.UtcNow() functioning correctly?
When I tested it today (9th April 2024) at 10:47 BST (which is one hour ahead of UTC), it returns "09/04/2024, 10:47:34.439". Surely it should have returned "09/04/2024, 09:47:34.439".
Am I missing something?
Solved! Go to Solution.
DateTimeZone.UtcNow() is a function in Power Query that returns the current date and time in Coordinated Universal Time (UTC). It should indeed return the current time in UTC regardless of the time zone of the machine running the query.
In your case, since you tested it on April 9th, 2024, at 10:47 BST (British Summer Time), which is one hour ahead of UTC, you are correct that the UTC time should have been 09:47:34.439, not 10:47:34.439.
It's possible that there might have been some issue with the environment or the Power Query implementation you're using. I'd recommend double-checking the system time settings and ensuring that there are no issues with the Power Query environment.
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
@johnbasha33 thanks for the suggestion. The surprising point is that DateTimeZone.UtcNow() is returning the value that I want (BST when it is BST in the UK and GMT when it is not), so I have removed my adjustment code and I get the answer that I want. I am merely wondering why DateTimeZone.UtcNow() is returning BST and not UTC.
DateTimeZone.UtcNow() is a function in Power Query that returns the current date and time in Coordinated Universal Time (UTC). It should indeed return the current time in UTC regardless of the time zone of the machine running the query.
In your case, since you tested it on April 9th, 2024, at 10:47 BST (British Summer Time), which is one hour ahead of UTC, you are correct that the UTC time should have been 09:47:34.439, not 10:47:34.439.
It's possible that there might have been some issue with the environment or the Power Query implementation you're using. I'd recommend double-checking the system time settings and ensuring that there are no issues with the Power Query environment.
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !!
@johnbasha33 the Power Query environment is a Dataflow in the Power BI Service. Before the UK move from GMT to BST at the end of last month DateTimeZone.UtcNow() was correctly returning the UTC time. Now the same query, running in the Power BI Service as part of a Dataflow is returning the time in BST. As it happens, this is very convenient for me as I had added logic for the next few years to adjust the UTC value to BST when appropriate. I have removed this logic now and I am getting the answer that I want (BST now, and GMT before) simply using DateTimeZone.UtcNow(). Are there custom settings in the Power BI Service that I should be aware of? It is a regular Power BI Pro account.
you might wana reduce 1 hour in your code to be in sync with BST. @hughcjohnson
Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.
User | Count |
---|---|
24 | |
12 | |
11 | |
11 | |
8 |
User | Count |
---|---|
43 | |
25 | |
15 | |
14 | |
12 |