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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
Anonymous
Not applicable

Convert 'YYYYMDD' to date

Hello everyone,

 

I am trying to convert a text which is concatenate with different value like '2020128' for 2020 = Year, 1 = January, 28 = Day

It works for 2 digits month but for 1 digit month it shows an error.

For now I am using a conditionnal column to fix my issue for all numbers < 10. Like if 1 => "01" etc.

But I want to know if they are another option more efficient to do this ?

 

And also do you know if there are a list exhaustive of date pattern that Power Query or Dax can convert directly to a date ? 

Like 'YYYYMM', 'YYYY-MM-DD' etc. 

 

Thank you very much for your help,

Have a nice day,

Loveboch

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Add column

 

Text.Combine({Text.Start(Text.From([date], "en-US"), 4), Text.Middle(Text.From([date], "en-US"), 4, Number.From(Text.Length(Text.From([date], "en-US")))-6), Text.End(Text.From([date], "en-US"), 2)}, "/")

 

Capture1.JPG

change type

Capture2.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
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

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @Anonymous 

Add column

 

Text.Combine({Text.Start(Text.From([date], "en-US"), 4), Text.Middle(Text.From([date], "en-US"), 4, Number.From(Text.Length(Text.From([date], "en-US")))-6), Text.End(Text.From([date], "en-US"), 2)}, "/")

 

Capture1.JPG

change type

Capture2.JPG

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

az38
Community Champion
Community Champion

@Anonymous 

how does 1-digit day number look like in your data source?

for example, 1 september 2008 and 1 october 2008?


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
Anonymous
Not applicable

Thank you for your reply,

 

For the days it's always a 2 digits day like '28' or '04' but for the month it's 1 for all numbers < 10

az38
Community Champion
Community Champion

@Anonymous 

or try to add a custom column in Power Query

= #date(Number.FromText(Text.Start([Column1], 4)), Number.FromText(Text.Middle([Column1], 4, Text.Length([Column1])-6)), Number.FromText(Text.End([Column1], 2)))

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn
az38
Community Champion
Community Champion

@Anonymous 

create a column

Column = DATE(LEFT('Table'[Column1], 4), MID('Table'[Column1], 5, LEN('Table'[Column1])-6), RIGHT('Table'[Column1], 2))

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

Top Solution Authors