Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
davidwsw
Frequent Visitor

Converting UTC to local time with daylight saving

I have a date column in my database table in UTC and I want to convert it to my local time (Eastern Time), taking into account daily saving.

 

I tried to do it using the following PowerQuery functions:

  • DateTime.AddZone to add the time zone to the UTC time
  • DateTimeZone.ToLocal to convert UTC to local
  • DateTimeZone.RemoveZone to remove the time zone from the converted time

I also found some posts where people tried to do their own conversion.

https://community.powerbi.com/t5/Power-Query/Convert-Date-Time-in-UTC-to-Local-Time-with-Daylight-sa...

Do the PowerQuery functions not handle the conversion correctly? I'm a bit confused as to why further calculations are needed.

 

The screenshot below shows the result after using the PowerQuery functions. It looks like the time offset changed from -4 hours to -5 hours at 6AM UTC or 2AM Eastern time.

PowerQuery convert to local time.png

 

When I do the conversion using "AT TIME ZONE" in SQL, the result is slightly different.

https://learn.microsoft.com/en-us/sql/t-sql/queries/at-time-zone-transact-sql?view=sql-server-ver16

 

Here it looks like the offset changed from -4 hours to -5 hours at 2AM UTC.

SQL convert to local time.png

 

Which result is correct? The one in SQL or the one from PowerQuery?

 

 

 

 

 

 

 

1 REPLY 1
ppm1
Solution Sage
Solution Sage

Please see this video for one way to handle DST. Note that it works in desktop but not in the service.

(7) An easy way to handle Daylight Savings Time in Power Query - YouTube

 

Pat

Microsoft Employee

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors