# How to extract a date from a text string in Excel

Find the date pattern with SEARCH wildcards and convert it: `=DATEVALUE(MID(A2,SEARCH("20??-??-??",A2),10))`.

**Excel:** `=DATEVALUE(MID(A2,SEARCH("20??-??-??",A2),10))` (Microsoft 365 only)

**Google Sheets:** `=DATEVALUE(REGEXEXTRACT(A2,"\d{4}-\d{2}-\d{2}"))`

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Note | Date |
| Paid in full on 2026-03-05 by check |  |
| Refund issued 2026-04-18 |  |
| Follow up 2026-05-02 re: invoice 4471 |  |
| Shipped 2026-06-30, tracking sent |  |
| Renewal due 2026-09-15 |  |

Formula in B2, filled to B6: `=DATEVALUE(MID(A2,SEARCH("20??-??-??",A2),10))`

Result: 3/5/2026; 4/18/2026; 5/2/2026; 6/30/2026; 9/15/2026

## How it works

In SEARCH, `?` matches any single character, so "20??-??-??" finds where a date like 2026-03-05 starts in the note. MID takes the 10 characters from there and DATEVALUE turns them into a real date. In Google Sheets, REGEXEXTRACT pulls out the pattern directly.

## Other ways

- `=DATEVALUE(REGEXEXTRACT(A2,"\d{4}-\d{2}-\d{2}"))`: A regular expression for the date pattern. Google Sheets, and recent Excel 365 builds that have REGEXEXTRACT.

## Common mistakes

- Only the first date in the text is found. A second one needs a SEARCH that starts after the first.
- Dates written another way, like 3/5/2026, need a different pattern. In Google Sheets use `"\d{1,2}/\d{1,2}/\d{4}"`.

## Questions

**What if some notes have no date?**

Wrap it in IFERROR: `=IFERROR(DATEVALUE(MID(A2,SEARCH("20??-??-??",A2),10)),"")`.

**Can Excel use regular expressions?**

Recent Excel 365 builds have REGEXEXTRACT, so the Google Sheets formula works there as well.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/extract-a-date-from-text
