Forum Discussion
Power Query - Convert UTC to User's Client Local Time?
- Anonymous5 years ago
Hi bvy,
You can use ‘DateTimeZone.ToLocal’ Function in query editor to meet your need.
As you mentioned, you have a Power BI table with a date time field in UTC. Here is a sample and you can follow these steps:
Open Query Editor> under the Add column tab> click Add Custom Column> Under the formula part> copy and paste the following:
DateTimeZone.ToLocal([Original Time])Finally, you will get a result like this:
For more information, please see: DateTimeZone.ToLocal
By the way, 'DateTimeZone.ToLocal' function is not supported in Direct Query mode currently.
As a workaround, you can also realize your needs by using ‘DateTime.AddZone’ function.
This function adds the time zone hours as an offset to the input date time value and returns a new date time zone value.
For detailed operation steps, you can refer to this case: Convert UTC to client time zones
Hope it helps.
Best Regards,
Caitlyn Yan
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi bvy,
You can use ‘DateTimeZone.ToLocal’ Function in query editor to meet your need.
As you mentioned, you have a Power BI table with a date time field in UTC. Here is a sample and you can follow these steps:
Open Query Editor> under the Add column tab> click Add Custom Column> Under the formula part> copy and paste the following:
DateTimeZone.ToLocal([Original Time])
Finally, you will get a result like this:
For more information, please see: DateTimeZone.ToLocal
By the way, 'DateTimeZone.ToLocal' function is not supported in Direct Query mode currently.
As a workaround, you can also realize your needs by using ‘DateTime.AddZone’ function.
This function adds the time zone hours as an offset to the input date time value and returns a new date time zone value.
For detailed operation steps, you can refer to this case: Convert UTC to client time zones
Hope it helps.
Best Regards,
Caitlyn Yan
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
The new column is in text format. How can I converted it to datetime format? Thanks