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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
jrduboue
New Member

Converting specific text to date in PowerQuery

Hello all,

 

I have a text column with dates in the current format: "mddyyyy" or "mmddyyyy" or "0" (to indicate no date in the cell). Can I get assistance with how to convert these text strings into date values in the format "mm/dd/yyyy" or "null".

 

Example: 2012016 to 02/01/2016 and 0 to null or blank

 

Thank you in advance.

1 ACCEPTED SOLUTION
v-caliao-msft
Microsoft Employee
Microsoft Employee

Hi @jrduboue,

 

You can use Date.FromText to achieve this requirement. It returns a Date value from a set of date formats and culture value, following ISO 8601 format standard.
Date.FromText(date as nullable text, optional culture as nullable text) as nullable date 

Supported formats

  • yyyy-MM-dd

  • YYYYMMDD

  • M/d/yyyy

Reference
https://msdn.microsoft.com/en-us/library/mt260703.aspx

 

Regards,

Charlie Liao

View solution in original post

3 REPLIES 3
v-caliao-msft
Microsoft Employee
Microsoft Employee

Hi @jrduboue,

 

You can use Date.FromText to achieve this requirement. It returns a Date value from a set of date formats and culture value, following ISO 8601 format standard.
Date.FromText(date as nullable text, optional culture as nullable text) as nullable date 

Supported formats

  • yyyy-MM-dd

  • YYYYMMDD

  • M/d/yyyy

Reference
https://msdn.microsoft.com/en-us/library/mt260703.aspx

 

Regards,

Charlie Liao

Anonymous
Not applicable

not very useful. Our date format may vary such as: yymmdd, yyyymmmdd, ddmmmyy, ddmmyyyy,.... And we would like to get dates from our origin column in a specified format. Is there kind of function like: DateFromString(DateColumn, "yymmdd"). We can easily do this in other languages.


Supported formats
  • yyyy-MM-dd

  • YYYYMMDD

  • M/d/yyyy

 


FWIW, it also supports "MMM DD YYYY" and appears to correctly convert the DD to a valid day whether it is two or one digits, i.e., "02" or " 2"

 

I don't know the full support for Date.FromText() conversion, but add this one to the list.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

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.