Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Date value changes when transforming column type

I cannot figure out why changing a "DateTimeZone" column to type "Date" causes the date value to change.   First I convert my UTC DateTime to IST DateTimeZone = Table.AddColumn(#"table from databa...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Ok... I tried using Date.From() but noticed in the doco it says:

    • datetimezone: The date component of the local datetime equivalent of value.

    ..... So, it uses "local" datetime equivalent. Unsurprisingly, it gave me the same "error" as using Table.TransformColumnTypes

     

    It didn't take long on the doco page, though, to find the answer: DateTimeZone.RemoveZone()

    (then change column to "Date" format ๐Ÿ™‚)

    = Table.AddColumn(#"Changed Type", "DateTimeFrom", each DateTimeZone.RemoveZone([IST Time2]), type datetime)