Convert Text String to Date

dls0406

New Member
Joined
Oct 7, 2019
Messages
15
I have a text string containing either 7 or 8 (MDDYYYY or MMDDYYYY) digits which I want to convert to a date value. I can use the Text.PadStart to convert all of the text string to MMDDYYYY, but am still having a lot of trouble using the Date.FromText function to get this in date value. I am VERY NEW to power query so please describe in baby steps.

Here is my setup now, where [Original date] column contains text strings of 7 or 8 character. With the following custom column formula, I am getting an error in each cell
= Date.FromText( Text.PadStart([Original Date],8,"0"), "MMDDYYYY")

Am I missing something from a syntax point of view? I have seen instructions where I have to break the text string into 3 columns and then recombine, but I'd rather get it all done in one step and I can't imagine that is impossible.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result
I cannot post the data as it is confidential - not mine to share. However I would assume there must be an easy formula that someone with powerquery expertise can share, to convert an 8-digit text string into a date. The text string, for example, is 03232005 and I want powerquery to recognise it as a date (March 23, 2005, but any format is fine)
 
Upvote 0
I don't want confidential data but representative generic sample (more then one record)
 
Upvote 0
Okay....I cannot give data file, but this is a sample of what the data looks like that I would like to convert to something that is recognized as a date by powerquery.

Original Date (Formatted as Text "ABC")
3232005
6122018
12282009
10012006
 
Upvote 0
maybe add prefix 0, cut string to 8 characters from right then Text.Insert(Text.Insert([Original Date],2,"/"),5,"/") and Parse
 
Upvote 0

Forum statistics

Threads
1,214,515
Messages
6,119,973
Members
448,933
Latest member
Bluedbw

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top