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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
kattlees
Post Patron
Post Patron

How to convert text column to date or time

I have two columns in my database for date and time. The issue is they are entered as text.

Examples would be

082520        1258

051620         0700

 

Is there a way in power query to have these convert to a date and time field automatically? I was trying a custom column but can't figure out the code to use.

 

Thanks in advance.

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

Hi @kattlees ,

 

This is troublesome, maybe you can do this.

Please refer to my .pbix file.

v-lionel-msft_2-1598518203533.png

 

Best regards,
Lionel Chen

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

3 REPLIES 3
v-lionel-msft
Community Support
Community Support

Hi @kattlees ,

 

This is troublesome, maybe you can do this.

Please refer to my .pbix file.

v-lionel-msft_2-1598518203533.png

 

Best regards,
Lionel Chen

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

Anonymous
Not applicable

HI @kattlees 

In power query you have a function if it helps.

DateTime.FromText()

https://docs.microsoft.com/en-us/powerquery-m/datetime-fromtext

 

Alternatively you can use the DAX functions DATE() and TIME()

amitchandak
Super User
Super User

@kattlees , in Dax

 

Date = date(right([col1],2), left([col1],2), mid([col1],3,2))

time = time(left([col2],2),right([col2],2),)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors