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
NickFel
Frequent Visitor

Convert column from Text to Date

Ok I have a column in my data that has the year and month of an item captured.

The issue is that it is a text field that lists it as text in this format:

YYMM

 

I know I could split these and recombine them in the correct order and format it as date but that would take several steps.

 

Is there a more efficient way to perform this funtion?

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

Are all the years in the 2000s ?

 

you may have to modify the above if your column is only the last 2 year digits - YYMM

 

Column = DATE("20"&LEFT([Test],2), RIGHT([Test],2), 1)

 

YYMM 2 DATE.png 

View solution in original post

5 REPLIES 5
SqlJason
Memorable Member
Memorable Member

If the column is called [Test] and if the format is YYYYMM, I generally do

 

= DATE(LEFT([Test],4), RIGHT([Test],2),1)

 

 Careful about the year though. In your case, you only have YY instead of YYYY, so might have to concatenate 19 or 20 based on what you want.

Sean
Community Champion
Community Champion

Are all the years in the 2000s ?

 

you may have to modify the above if your column is only the last 2 year digits - YYMM

 

Column = DATE("20"&LEFT([Test],2), RIGHT([Test],2), 1)

 

YYMM 2 DATE.png 

NickFel
Frequent Visitor

Thanks this woked

 

Interesting I'm getting an error that the name date wasn't recognized?

Forgot to tell you,  I did this in DAX (the modelling side) and not in M (query editor side)

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.