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
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through June10th!

Power BI Dev Camp Session 22 without aka link and time 768x460.jpg

Check it Out!

Watch Session 22 Ted's Dev Camp along with past sessions!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Kudoed Authors