Forum Discussion
TeisL
2 years agoFrequent Visitor
Powerquery US date Text to DateTime format
Hi everyone, I want to transform a text value (MM/DD/YYY hh:mm:ss) into a datetime (DD/MM/YYYY hh:mm:ss) value. Example of the data: Created date New date 3/7/2019 1:25:03 PM 7/3/2019...
tackytechtom
2 years agoMost Valuable Professional
Hi TeisL ,
How about this:
Here the Power Query M code for the new custom column:
try DateTime.FromText(
Text.Split( Text.From( [date]), " " ){0} &" "&Text.Split( Text.From( [date]), " " ){1},[Format = "MM/dd/yyyy h:mm:ss"]) otherwise
try DateTime.FromText(
Text.Split( Text.From( [date]), " " ){0} &" "&Text.Split( Text.From( [date]), " " ){1},[Format = "M/dd/yyyy h:mm:ss"]) otherwise
try DateTime.FromText(
Text.Split( Text.From( [date]), " " ){0} &" "&Text.Split( Text.From( [date]), " " ){1},[Format = "MM/d/yyyy h:mm:ss"]) otherwise
DateTime.FromText(
Text.Split( Text.From( [date]), " " ){0} &" "&Text.Split( Text.From( [date]), " " ){1},[Format = "M/d/yyyy h:mm:ss"])
Note, I called the original column "date". You need to align the code accordingly.
Also, I took the code from here and aligned it a bit:
Converting dates from MM/DD/YYYY to DD/MM/YYYY in ... - Microsoft Fabric Community
Hope this helps 🙂
/Tom
https://www.tackytech.blog/
https://www.instagram.com/tackytechtom/