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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
anglefbi11
Regular Visitor

mutliple time format issue

hi dears

i am using power query and i am facing a complicated issue with time format. i have a data with mixed 12 hours, 24 format . i need to know how to get them all as the same format . i treid using spilit and extract function but with no luck. 

 

 

some of the date format is listed like:

 

02/12/2024 23:14

 

and some of them like

2/13/24 12:35 AM

 

you can notice that year in the first date is YYYY and time is 24 format.  in the second date the year is YY and timing is 12 hrs format

 

kindly find the below 

 

 

 

anglefbi11_1-1713802141608.png

 

1 ACCEPTED SOLUTION
anglefbi11
Regular Visitor

hi guys

 

thanks god i found the soulution finally . i changed my regional format in my pc from english UK to English US and it has been solved

View solution in original post

7 REPLIES 7
anglefbi11
Regular Visitor

hi guys

 

thanks god i found the soulution finally . i changed my regional format in my pc from english UK to English US and it has been solved

amustafa
Super User
Super User

Try adding locale to your code. Like this example.

= Table.TransformColumnTypes(#"Promoted Headers", {{"DATE", type datetime}}, "en-US")





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




anglefbi11
Regular Visitor

dears

kindly look what happened when i change the column to date and time

 

anglefbi11_0-1713806823674.png

 

This will solve your issue. Add as custom column:

 

try DateTime.FromText([Date], "en-US") otherwise DateTime.FromText([Date], [Format="M/d/yy hh:mm tt", Culture="en-US"])

 

If you want to transform existing [Date] column, add this as new step (just replace Previous_Step😞

= Table.TransformColumns(Previous_Step, {{"Date", each try DateTime.FromText(_, "en-US") otherwise DateTime.FromText(_, [Format="M/d/yy hh:mm tt", Culture="en-US"]), type datetime}})

 


Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

amustafa
Super User
Super User

Please provide a sample data in a file you are importing into Power Query.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




amustafa
Super User
Super User

Simply change the column data type to Date/Time...

= Table.TransformColumnTypes(Source,{{"DATE", type datetime}})





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




i did and nothing change. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors