Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Type changes are setting local timezone on date times

When you have a value that is in datetimezone format and set it to datetime the value of the time will be changed to the datetime in my timezone. I do not think this was a behaviour in earlier versions but I may be mistaken.

Either way I think the value itself should not be changed when a type conversion occurs.

 

Execute the following M code and you will see the issue

let
Source = DateTimeZone.UtcNow(),
#"Converted to Table" = #table(1, {{Source}}),
#"Changed Type" = Table.TransformColumnTypes(#"Converted to Table",{{"Column1", type datetimezone}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"Column1", type datetime}})
in
#"Changed Type1"

 

Value converted to BSTstarting value in UTC

 

  • Hi Anonymous,

     

    This is expected, as the DateTimeZone.UtcNow() returns dateTime value set to the current system date and time in the Utc timezone. When we change the value to datetime data type, the timezone information is removed, the value will display based on current system local timezone. 

     

    Best Regards,
    Qiuyun Yu

1 Reply

  • v-qiuyu-msft's avatar
    v-qiuyu-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous,

     

    This is expected, as the DateTimeZone.UtcNow() returns dateTime value set to the current system date and time in the Utc timezone. When we change the value to datetime data type, the timezone information is removed, the value will display based on current system local timezone. 

     

    Best Regards,
    Qiuyun Yu