A column in Power Query converts a JavaScript timezone into UK format:
= #datetime(1970, 1, 1, 0, 0, 0) + #duration(0, 0, 0, [Timestamp]/1000)
But this produces the wrong output (-1hr difference), presumably due to UTC / GMT+Summertime differences?
I tried to convert again using the following code:
= DateTimeZone.ToLocal(#datetime(1970, 1, 1, 0, 0, 0) + #duration(0, 0, 0, [Timestamp]/1000))
But I get the error:
Expression.Error: We cannot convert the value #datetime(2019, 7, 11, 23, 11, 40) to type DateTimeZone.
Details:
Value=11/07/2019 23:11:40
Type=Type
How do I do this properly?
Edit:
Timestamp = Text.BetweenDelimiters([ReceivedTime], "(", ")"), type text
where [ReceivedTime]
is a JSON date in milli-seconds like: /Date(1562886700000)/
There may be a more sensible way to convert a JSON date without resorting to Text
methods.
The resulting solution should display correctly in Power BI reports - the reports should display all datetimes in the user's Local Timezone.
DateTimeZone.ToLocal(DateTimeZone.From(#datetime(1970, 1, 1, 0, 0, 0) + #duration(0, 0, 0, [Timestamp]/1000)))
– Connett