Explanation
The DATE function creates a valid date using three arguments: year, month, and day:
=DATE(year,month,day)
In cell C6, we use the LEFT, MID, and RIGHT functions to extract each of these components from a text string, and feed the results into the DATE function:
=DATE(LEFT(B6,4),MID(B6,5,2),RIGHT(B6,2))
The LEFT function extracts the leftmost 4 characters for year, the MID function extracts characters in positions 5-6 for month, and the RIGHT function extracts the rightmost 2 characters as day. Each result is returned directly to the DATE function. The final result is a proper Excel date that can be formatted any way you like.
This approach can be customized as needed. For example, the unrecognized date format in row 8 is dd.mm.yyyy and the formula in C8 is:
=DATE(RIGHT(B8,4),MID(B8,4,2),LEFT(B8,2))
Long form text
Sometimes you may have dates in a longer form like "Apr 11 2020 08:43:13" that Excel does not recognize properly. In this case, you may be able to adjust the string in a way that allows Excel to correctly recognize the date with the SUBSTITUTE function. The formula below replaces the second instance of a space (" ") with a comma and space (", "):
=SUBSTITUTE(A2," ",", ",2)+0 // add comma after month
Once we add the comma after the month name, Excel will understand the date, but it still needs a little "kick". That's why we add zero at the end. The math operation causes Excel to try and convert the string to a number. When successful, this will result in a valid Excel date. Note you may need to apply date number formatting to display the date correctly.
Without formulas
Before you use a formula to manually parse and construct a date from text, try one of the fixes below. The first option uses a math operation to "nudge" Excel a bit and force it to try and evaluate the text as a number. Because Excel dates are in fact numbers, this can often do the trick. You may need to apply a date format if the operations succeeds.
Add zero to fix dates
Sometimes, you'll encounter dates in a text format that Excel should recognize. In this case, you might be able to force Excel to convert the text values into dates by adding zero to the value. When you add zero, Excel will try to coerce text values to numbers. Since dates are just numbers, this trick is a great way to convert dates in text format that Excel really should understand.
To convert dates in place by adding zero, try Paste Special:
- Enter zero (0) in an unused cell and copy to the clipboard
- Select the problematic dates
- Paste Special > Values > Add
- Apply a date format (if needed)
You can also add zero in a formula like this:
=A1+0
where A1 contains an unrecognized date.
Text to columns to fix dates
Another way to get Excel to recognize dates is to use the Text to Columns Feature:
Select the column of dates, then try Data > Text to columns > Fixed > Finish
If Excel recognizes the dates, it will fix them all in one step.