Excel: Extract Date from Text String How do i extract a date from a text string?

Assuming your text string is in cell A1, you can use the following formula to extract the date:

=DATE(LEFT(A1,4),MID(A1,5,2),RIGHT(A1,2))

This formula assumes that the date is in the format YYYY-MM-DD.


You can use the following formula to extract a date from a text string in Excel:

=MID(" "&A2,FIND("/"," "&A2,1)-2,10)

The following example shows how to use this formula in practice.

Example: Extract Date from Text String in Excel

Suppose we have the following column of text strings in Excel that all contain a date somewhere in the string:

Suppose we would like to extract the date from each text string.

To do so, we can type the following formula into cell B2:

=MID(" "&A2,FIND("/"," "&A2,1)-2,10)

We can then click and drag this formula down to each remaining cell in column B:

Excel extract date from string

Column B now contains the date from each text string in column A.

Note that if your date is in a different format than mm/dd/yyyy then you can modify the formula.

For example, if your date is in the format mm-dd-yyyy then you can replace the slash in the FIND function with a dash:

=MID(" "&A2,FIND("-"," "&A2,1)-2,10)

The following screenshot shows how to use this formula in practice:

How This Formula Works

Recall the formula that we used to extract the date from the text string in the first example:

=MID(" "&A2,FIND("/"," "&A2,1)-2,10)

Here is how this formula works:

First, we use the FIND function to return the position of the first slash in each text string. 

For example, in the string My birthday is on 10/12/2023 this function returns 22.

Then we subtract 2 to get 20.

Then we use the MID function to return all of the text in the middle of the string starting from position 20 to 10 additional characters.

Thus, the formula returns 10/12/2023.

We use this same logic to extract the date from each text string.

x