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
HotChilli
7 years agoCommunity Champion
I think you want to create durations from your data and just add(+) them to your datetime.
yourdatetime + #duration()
duration is (dd,hh,mm,ss) so a duration of 1 hour is (0,1,0,0)
The datetimezone will create you a datetime (yy: mm: dd : hh : mm : ss) with an additional offset of hh : mm, which is not really what you want, I think.
ericOnline
7 years agoPost Patron
Hi HotChilli. How is your suggested implemented?
I have a table of 1800 rows. Depending on the ID# column of each record I want to programmatically add/remove hours to a DateTime column that is in UTC format.
I'm new at PowerBI so need some more details.
Thank you