Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
vincenardo
Helper I
Helper I

Convert Date Time in UTC to PST

I have a date / time field coming in from a connection to Salesforce. The date/time is stored in UTC and I need to transform it to PST (our local time).

 

I tried to edit the query and 'transform' it by changing the data type to DATE/TIME/TIMEZONE. All this did was add the time zone to the field..

 

vincenardo_0-1629342980113.png

 

How do I convert this value to the current time zone??

 

Thanks!!

 

13 REPLIES 13
Anonymous
Not applicable

@vincenardo 
DateTimeZone.ToLocal() should work. This blog explains the steps in details.

Handling Different Time Zones in Power BI / Power Query


What is the original data type of the screen short date columns? For the errors, Is is possible to share a pbix file including a short sample.

 

 

Paul Zheng _ Community Support Team

Anonymous
Not applicable

Can you tell me what the error says, or post the M code from the advanced editor?

You could also try adding the word "each" before the DateTimeZone functions. Or, try replacing DateTimeZone.ToLocal with each DateTimeZone.SwitchZone(_, -8). Whatever you do though, you should do it  once, in other words, don't change the type to DateTimeZone earlier in the query, unless you use each DateTime.AddZone([AbsentStart], -8).

 

--Nate

 

--Nate

Here is the error -

 

Expression.Error: We cannot convert the value #datetime(2020, 8, 18, 19, 30, 0) to type DateTimeZone.
Details:
Value=8/18/2020 7:30:00 PM
Type=[Type]

Anonymous
Not applicable

At any rate, if the column was originally type datetime, you can use DateTime.AddZone([AbsentStart], -8) to convert to your time zone, or just [AbsentStart] - #duration(0,8,0,0)

 

--Nate

Anonymous
Not applicable

Try this:

 

= Table.TransformColumns(#"Resource Absence", {{"AbsentStart", DateTimeZone .ToLocal}, {"AbsentEnd", DateTimeZone.ToLocal}})

I recieved this error; ??

vincenardo_0-1629554626723.png

Expression.Error: A cyclic reference was encountered during evaluation

 

Anonymous
Not applicable

Ok, your last step name is #"Reordered Columns1", so:

 

= Table.TransformColumns(#"Reordered Columns1", {{"AbsentStart", DateTimeZone .ToLocal}, {"AbsentEnd", DateTimeZone.ToLocal}})

 

 

Appreciate the help, still have an issue;

Here is the dataset before I put in the Code you suggested (The AbsentStart_PST was using a different way to conver the AbsentStart)

vincenardo_0-1629556561926.png

 

I inserted the code you suggested (Custom1) - and I get this error on the AbsentStart and AbsentEnd.

 

vincenardo_1-1629556617496.png

 

Any ideas? I like your suggestion the best because the code is much less then what I used and will ensure the time is coverted to the local time.

 

 

 

When editing the table, can you give me the steps on where to add it? I can't figure where to place it, I assume it's not in a new column. Thanks!

Anonymous
Not applicable

Sorry, under your applied steps, right click on the last step, click "Add new step". Then copy and paste everything including the "=" into the formula bar. 

Anonymous
Not applicable

To make the Datetime correct its value, as opposed to only adding the Time Zone, just use this one function, instead of changing the data type to datetimezone:

= Table.TransformColumns(PriorStepOrTableName, {{"AbsentStart", DateTimeZone .ToLocal}, {"AbsentEnd", DateTimeZone.ToLocal}})

 

This will add your local time zone to the datetime,  and also offset the actual value by the difference in hours from UTC to PST.

 

--Nate

Can you give me some additional instructions on how to add this? The table name is ‘Resource Absence’ not sure where to add this…

Thank you!

PC2790
Community Champion
Community Champion

Hello @vincenardo 

 

Check this out-https://cloudbi.com.au/converting-utc-to-local-datetime-in-power-bi/

It might be able to address your requirement

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors
Top Kudoed Authors