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
RafaelKnuth
Advocate I
Advocate I

M-Language: How to convert date format from European to US?

I was wondering how to write a function in M that would convert date formats from EU to US?

Example: December 31st, 2010 needs to be transformed from 31/12/2010 to 12/31/2010

 

DateEU.PNG

 

Below an exemplary Excel function - I was wondering if I can perform that date transformation with M in my Power Query?

 

DateFormat.PNG

 

I went through the Power Query M Function reference, but I couldn't find a function that allows me to reverse a value in any desired order (I only found one function that allows me to reverse in one specific order: 1234 would become 4321 but that's not the solutiuon I want).

As a temporary workaround, I would split the Date EU column into 3 columns by the slash delimiter, and then merge those columns in reversed order. But that's a very creepy, unelegant solution IMHO.

 

Any ideas? Thanks a lot in advance!

2 REPLIES 2
v-yulgu-msft
Employee
Employee

Hi @RafaelKnuth,

 

You can try Date.ToText function.

=Date.ToText([date],"MM/dd/yyyy")

1.PNG

 

Besides, you can try to convert date using Local.

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Yuliana,

thanks for your help!

It partially worked - the solution you suggested didn't work on my computer (I tried different variations), Reza's solution did work, but only in one specific case. To me it seems that proper date conversion depends on multiple factors (such as Locale settings). That's a tricky one 😉 There are so many odd date formats people are using.

Best,

Rafael

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.