Forum Discussion
Dates reverting to UTC when published to web from desktop
- 9 years ago
Hi CourtneyLeah,
I also tried that and what I think it does in the Power BI Service, is that all the servers are set to UTC.
So because the server time where the files are hosted is set to UTC it then uses the DateTimeZone.ToLocal which is indeed is UTC.
I would rather suggest using the syntax I provided earlier, as I have tested this and once I have uploaded it to the Power BI Service, it does display the correct time.
Does this account for daylight savings time?
I have been trying to solve the daylight savings time problem using different datetime and datetimezone functions and I have not fount anyone that helps me. So, I have written the following function to convert 2016 and 2017 datetimes:
if [FECHAUTC] = null then null
else if [FECHAUTC] > #datetime(2017,10,29,3,0,0) then DateTime.AddZone([FECHAUTC], -1)
else if [FECHAUTC] > #datetime(2017,3,26,2,0,0) then DateTime.AddZone([FECHAUTC], -2)
else if [FECHAUTC] > #datetime(2016,10,30,3,0,0) then DateTime.AddZone([FECHAUTC], -1)
else if [FECHAUTC] > #datetime(2016,3,27,2,0,0) then DateTime.AddZone([FECHAUTC], -2)
else DateTime.AddZone([FECHAUTC], -1) as nullable datetimezone
I´m adding -1 and -2 hour to the UTC datetime because I want the correct hour for Spain. You have to change this value in order to calculate the correct time for your country.
Note that FECHAUTC is a datetime.
It is not the best solution. I think Microsoft should include a regional configuration in Power BI web, but currently ir is solving my problem.
Hope it helps you.