Forum Discussion
convert text to date
- 3 years ago
Hi Aha2022
You can first add a custom column to get the date values without "st/nd/rd/th" into a new column.
Text.RemoveRange([Date], Text.PositionOf([Date], " ")-2, 2)Then change the new column to Date type. With the new format, dates can be converted into Date type successfully.
If you want to change the format of dates, you need to apply the data to Power BI Desktop and change the column format there, just like below image. In Power Query Editor, it doesn't support to change the date format when the column is of Date type.
If you don't want to add a custom column to get the new date values, you can transform the original column with the following M code. Then modify the column type to Date and apply it to Power BI Desktop to change the date format.
= Table.TransformColumns(#"Changed Type", {{"Date", each Text.RemoveRange(_, Text.PositionOf(_, " ")-2, 2)}})Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.
Hi Aha2022
You can first add a custom column to get the date values without "st/nd/rd/th" into a new column.
Text.RemoveRange([Date], Text.PositionOf([Date], " ")-2, 2)
Then change the new column to Date type. With the new format, dates can be converted into Date type successfully.
If you want to change the format of dates, you need to apply the data to Power BI Desktop and change the column format there, just like below image. In Power Query Editor, it doesn't support to change the date format when the column is of Date type.
If you don't want to add a custom column to get the new date values, you can transform the original column with the following M code. Then modify the column type to Date and apply it to Power BI Desktop to change the date format.
= Table.TransformColumns(#"Changed Type", {{"Date", each Text.RemoveRange(_, Text.PositionOf(_, " ")-2, 2)}})
Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.