Forum Discussion

sandra_p's avatar
sandra_p
Helper I
6 years ago
Solved

DateTimeZone not recognized when using DateTimeZone.SwitchZone(DateTime.LocalNow(),3,0)

Hello,

 

I want to add to my reports the date and time when report was refreshed.

I have found the approach, but the problem is that in Power BI Service time zone is different, so I need to adjust it.

I have tried this:

let
Source = #table(type table[Date Last Refreshed=datetimezone], {{DateTimeZone.SwitchZone(DateTime.LocalNow(),3,0)}})
in
Source

 

Get error:

Expression.Error: We cannot convert the value #datetime(2020, 6, 18, 11, 45, 34.8464175) to type DateTimeZone. Details: Value=18/06/2020 11:45:35 Type=[Type]
 
And I tried this:
let
Source = #table(type table[Date Last Refreshed=datetimezone], {{DateTime.LocalNow()}}),
#"Added Custom" = Table.AddColumn(Source, "My time", each DateTimeZone.SwitchZone([Date Last Refreshed],3,0))
in
#"Added Custom"
 
Same error happens.
 
Why "Date Last Refreshed" is not recognized as DateTimeZone even if it has this type?

4 Replies