Forum Discussion
h4tt3n
Helper V
6 years agoConvert a columns of datatype datetimezone to datetime
Hello, I have a table with timestamped data of datatype datetimezone, eg. 07-08-2020 08:00:00 + 02:00. How do I convert this to datetime in a way that takes tz info into account, eg. 07-08-2020...
dufoq3
Community Champion
1 year agoEDIT: I've just noticed that this is almost 5 years old topic, but maybe it will help to someone...
Hi h4tt3n, check this:
let
Source = #table(null, {{"07-08-2020 08:00:00 +02:00"}}),
Ad_CorrectDateTime = Table.AddColumn(Source, "CorrectDateTime", each let a = DateTimeZone.From([Column1]) in DateTime.From(a) + #duration(0, DateTimeZone.ZoneHours(a), DateTimeZone.ZoneMinutes(a), 0), type datetime)
in
Ad_CorrectDateTime
If there is a space after + sign (as you showed us in your sample) use this:
let
Source = #table(null, {{"07-08-2020 08:00:00 + 02:00"}}),
Ad_CorrectDateTime = Table.AddColumn(Source, "CorrectDateTime", each let a = DateTimeZone.From(Text.Combine(Text.Split([Column1], " + "), " +")) in DateTime.From(a) + #duration(0, DateTimeZone.ZoneHours(a), DateTimeZone.ZoneMinutes(a), 0), type datetime)
in
Ad_CorrectDateTime