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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

Converting datetime from text data type in UTC format

Hi,

 

I am cracking my head trying to convert the data type from text to datetime using the DateTime.FromText function in Power Query.

Basically, I have the following text format:

Oct 23, 2022 8:00PM UTC

 

I tried the following function, but it did not work:

 

DateTime.FromText([ColumnName], [Format="MMM dd, yyyy h:mmtt"])

 

I know that I also have to define the local culture as a parameter but not sure if there is such for UTC format. I think there is something wrong with how I am providing the format code or maybe there is an easiest solution to do that.

 

Any good soul can help?

1 ACCEPTED SOLUTION
jennratten
Super User
Super User

Hello - this will make the conversion:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8k8uUTAy1lEwMjAyUrCwMjAI8FUIDXFWio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    DateTimeUTC = Table.AddColumn(Source, "DateTimeUTC", each DateTime.AddZone(DateTime.FromText(Text.BeforeDelimiter([Column1], " UTC")),0)),
    #"Changed Type" = Table.TransformColumnTypes(DateTimeUTC,{{"DateTimeUTC", type datetimezone}})
in
    #"Changed Type"

jennratten_0-1679428428938.png

 

View solution in original post

2 REPLIES 2
jennratten
Super User
Super User

Hello - this will make the conversion:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45W8k8uUTAy1lEwMjAyUrCwMjAI8FUIDXFWio0FAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    DateTimeUTC = Table.AddColumn(Source, "DateTimeUTC", each DateTime.AddZone(DateTime.FromText(Text.BeforeDelimiter([Column1], " UTC")),0)),
    #"Changed Type" = Table.TransformColumnTypes(DateTimeUTC,{{"DateTimeUTC", type datetimezone}})
in
    #"Changed Type"

jennratten_0-1679428428938.png

 

Anonymous
Not applicable

This is great! Thank so much @jennratten 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.