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
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

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 May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Dev Camp Session 22 768x460.jpg

Check it out!

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