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
jch
Employee
Employee

We can't automatically convert the column to Date type - text in format of YYYYMMDD to a Date value

When we try to convert date values in text fields formatted like 20180620 (YYYYMMDD) to a Date type in Query Editor, we get the error:

"We can't automatically convert the column to Date type"

 

Is there a more elegant solution than concatenating substrings of this field to look like a date?


Thanks in advance

2 ACCEPTED SOLUTIONS
v-yiruan-msft
Community Support
Community Support

Hi @jch ,

Has your problem been solved? If not, you can check the solutions in the following threads with similar problem to yours to see if they can help you solve the problem.

> Change the locale to a country where use YYYYMMDD in Regional setting tab (File > Options and settings > Options > Regional Settings)

Change column type to Date in Power BI

Changing the date format in Power BI - How does it work?

yingyinr_0-1634711566266.png

Power BI Date Formatting

Best Regards

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

View solution in original post

d_gosbell
Super User
Super User

Changing the regional settings of the report is not really an elegant solution and will not work if you have multiple sources with different date formats.

 

There are a number of better solutions to this issue.

 

1. If the column is being detected as a number, first change it to text then add another step to convert to a date. This worked fine on my machine when using an unambiguous format like yyyymmdd.

 

2. The other option is to add a Custom Column where you can use the Date.FromText() function. You can then use the optional second parameter to change the culture used to parse the text. 

 

eg. Date.FromText( [Column1] , "en-US") would interpret 6/9/2018 as 9 June 2018 (m/d/yyyy)
      Date.FromText( [Column1], "en-AU" ) would interpret 6/9/2018 as 6 Sept 2018 (d/m/yyyy)

View solution in original post

3 REPLIES 3
d_gosbell
Super User
Super User

Changing the regional settings of the report is not really an elegant solution and will not work if you have multiple sources with different date formats.

 

There are a number of better solutions to this issue.

 

1. If the column is being detected as a number, first change it to text then add another step to convert to a date. This worked fine on my machine when using an unambiguous format like yyyymmdd.

 

2. The other option is to add a Custom Column where you can use the Date.FromText() function. You can then use the optional second parameter to change the culture used to parse the text. 

 

eg. Date.FromText( [Column1] , "en-US") would interpret 6/9/2018 as 9 June 2018 (m/d/yyyy)
      Date.FromText( [Column1], "en-AU" ) would interpret 6/9/2018 as 6 Sept 2018 (d/m/yyyy)

v-yiruan-msft
Community Support
Community Support

Hi @jch ,

Has your problem been solved? If not, you can check the solutions in the following threads with similar problem to yours to see if they can help you solve the problem.

> Change the locale to a country where use YYYYMMDD in Regional setting tab (File > Options and settings > Options > Regional Settings)

Change column type to Date in Power BI

Changing the date format in Power BI - How does it work?

yingyinr_0-1634711566266.png

Power BI Date Formatting

Best Regards

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

is the date format is same through out the whole column? please confirm if it is same in the whole column and do not have any alphapet or character in it. Then try changingt the data type to "Whole Numbers" first and then to Date type.  

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.