Forum Discussion
ericOnline
7 years agoPost Patron
Convert utc to local time zone using Power Query
Hello, Does anyone have a better example for how to add hours (DateTime.AddZone) to a date-time value? The docs are not clear on this: DateTime.AddZone(#datetime(2010, 5, 4, 6, 5, 5), 8) equals...
- 7 years ago
Hi ericOnline,
Based on my test, you could refer to below steps in query editor:
Add custom column:
if [ID]=1 then [Date]+#duration(0,2,0,0) else if [ID]=2 then[Date]+#duration(0,1,0,0) else null
Result:
You could also download the pbix file to have a view.
Regards,
Daniel He
hinteadan
7 years agoNew Member
This solution is not correct because it doesn't take into account Daylight Saving Time.
ericOnline
7 years agoPost Patron
Hi hinteadan. Not “complete” in all use cases, but it is “correct”. Key word being time “zone”. If you needed to convert to local “time”, then yes, an additional column for DST is required.
Have you found a solution for this additional parameter?
Have you found a solution for this additional parameter?
- hinteadan7 years agoNew MemberHello ericOnline, you are right, it's rather incomplete not incorrect. DST is a sneaky **bleep** which we tend to forget about, but actually want to consider when converting timestamps. I removed my original reply and posted one with the URL for the solution that includes DST.
- ericOnline7 years agoPost PatronHi hinteadan. You’re right! I haven’t shared the app with anyone outside my time zone so didn’t encounter the issue pointed out in the blog. Great catch. Thanks for posting this!