cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
danextian
Community Champion
Community Champion

DateTimeZone.UtcNow() not working properly in Power BI Service

I have a report that is scheduled to refresh once daily and I need to show the users when the report's dataset was last refreshed.

 

I understand that refreshing a query via service with a DateTime.LocalNow() formula will return the server's timezone instead of the report author's/dataset owner's. Instead, I'm using DateTimeZone.UtcNow() then convert it to my timezone ( +8 ) using DateTimeZone.SwitchZone.  Like DateTime.LocalNow(),  DateTimeZone.UtcNow() works fine when refreshed via desktop but is showing a time 8 hours late than than my current time when refreshed in the service. For example, I refreshed the data set 12 noon my time but the report is showing 4 am instead. 

 

Please let me know what I am missing. 




Did I answer your question? Mark my post as a solution!
"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
www.linkedin.com/in/danebelarminocpa
1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@danextian,

 

Power BI service shows the current date and time in UTC. To solve this issue, you may try the following ways:

  1. Create a measure := Now() + timezoneHours / 24
  2. Create Custom Column in Query Editor: Formula= DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),timezoneHours,0)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-chuncz-msft
Community Support
Community Support

@danextian,

 

Power BI service shows the current date and time in UTC. To solve this issue, you may try the following ways:

  1. Create a measure := Now() + timezoneHours / 24
  2. Create Custom Column in Query Editor: Formula= DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),timezoneHours,0)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),timezoneHours,0) works. Thanks for this. 

 

By the way, would you know what timeonze DateTimeZone.UtcNow() is using?




Did I answer your question? Mark my post as a solution!
"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
www.linkedin.com/in/danebelarminocpa

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors