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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

how to convert date/time/timezone to standardized timezone

I have a field of type Date/Time/Timezone.  Two sample values are:

11/24/2020 9:28:09 AM -06:00

11/25/2020 5:45:08 AM -07:00

 

In Power Query, I need to convert all of these values to Central Standard Time (CST).  How can I achieve this?

 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Anonymous 

Download example PBIX file here with this query

Assuming that the last part of the Date/Time/TZ values is the offset from GMT e.g. -06:00 then this query converts all such values to CST which is 6 hours behind GMT

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTUNzLRNzIwMlCwtDKysDKwVHD0VdA1MLMyMFCK1YEoMIUoMLUyMbUysIAoMCekwAi/Am0DE7CCWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Column1.1", "Column1.2"}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter", "Column1.2", Splitter.SplitTextByEachDelimiter({":"}, QuoteStyle.Csv, false), {"Column1.2.1", "Column1.2.2"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Column1.2.2", Int64.Type}, {"Column1.2.1", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Minutes", each [Column1.2.2]/60),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column1.2.2"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Column1.2.1", "Hours"}}),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Renamed Columns", {{"Column1.1", type datetime}}, "en-US"),
    #"Added Custom2" = Table.AddColumn(#"Changed Type with Locale", "CST", each [Column1.1] + #duration(0,(6+[Hours])*-1,0,0))
in
    #"Added Custom2"

 

tz-change.png

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

1 REPLY 1
PhilipTreacy
Super User
Super User

Hi @Anonymous 

Download example PBIX file here with this query

Assuming that the last part of the Date/Time/TZ values is the offset from GMT e.g. -06:00 then this query converts all such values to CST which is 6 hours behind GMT

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjTUNzLRNzIwMlCwtDKysDKwVHD0VdA1MLMyMFCK1YEoMIUoMLUyMbUysIAoMCekwAi/Am0DE7CCWAA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Split Column by Delimiter" = Table.SplitColumn(Source, "Column1", Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true), {"Column1.1", "Column1.2"}),
    #"Split Column by Delimiter1" = Table.SplitColumn(#"Split Column by Delimiter", "Column1.2", Splitter.SplitTextByEachDelimiter({":"}, QuoteStyle.Csv, false), {"Column1.2.1", "Column1.2.2"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Split Column by Delimiter1",{{"Column1.2.2", Int64.Type}, {"Column1.2.1", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Minutes", each [Column1.2.2]/60),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"Column1.2.2"}),
    #"Renamed Columns" = Table.RenameColumns(#"Removed Columns",{{"Column1.2.1", "Hours"}}),
    #"Changed Type with Locale" = Table.TransformColumnTypes(#"Renamed Columns", {{"Column1.1", type datetime}}, "en-US"),
    #"Added Custom2" = Table.AddColumn(#"Changed Type with Locale", "CST", each [Column1.1] + #duration(0,(6+[Hours])*-1,0,0))
in
    #"Added Custom2"

 

tz-change.png

Regards

Phil


If I answered your question please mark my post as the solution.
If my answer helped solve your problem, give it a kudos by clicking on the Thumbs Up.



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


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