Forum Discussion
Applicable88
5 years agoImpactful Individual
Get the right date from time switch zone function
Hello, I use this function to work against the utc+2 time lap: Time.Hour(DateTimeZone.SwitchZone(DateTimeZone.LocalNow(),2,0)) I have different calculation based on different times. I wante...
- 5 years ago
Hi Applicable88 ,
Use below M code to get the right day:
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ31TcyUDA0sDIyc/RVio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Datetime = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Datetime", type datetime}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each DateTimeZone.SwitchZone(DateTimeZone.From(DateTime.LocalNow()),2,0)), in #"Added Custom"DateTimeZone.SwitchZone(DateTimeZone.From(DateTime.LocalNow()),2,0)
pls check my .pbix file attahched.
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
v-kelly-msft
5 years agoCommunity Support
Hi Applicable88 ,
Use below M code to get the right day:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMtQ31TcyUDA0sDIyc/RVio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Datetime = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Datetime", type datetime}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each DateTimeZone.SwitchZone(DateTimeZone.From(DateTime.LocalNow()),2,0)),
in
#"Added Custom"
DateTimeZone.SwitchZone(DateTimeZone.From(DateTime.LocalNow()),2,0)
pls check my .pbix file attahched.
Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Applicable88
5 years agoImpactful Individual
thanks v-kelly-msft !