How to extract a date from a text string in Excel
Excel formula
=DATEVALUE(MID(A2,SEARCH("20??-??-??",A2),10))Find the date pattern with SEARCH wildcards and convert it: =DATEVALUE(MID(A2,SEARCH("20??-??-??",A2),10)).
- Result on the example
- one result per row in
B2, filled down toB6 - Works in
- Microsoft 365 only
- Google Sheets
- Different formula, see below
See it work
The formula is already in B2, filled down to B6. Change any input and the result updates, or edit the formula to experiment.
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.
=DATEVALUE(MID(A2,SEARCH("20??-??-??",A2),10))Result3/5/2026 (46086)
A2"Paid in full on 2026-03-05 by check"The value in A2.
SEARCH("20??-??-??",A2)17SEARCH: Position of text, not case-sensitive, allows wildcards.- find_text
"20??-??-??" - within_text
A2"Paid in full on 2026-03-05 by check"
- find_text
MID(A2,SEARCH("20??-??-??",A2),10)"2026-03-05"MID: Characters from the middle of text.- text
A2"Paid in full on 2026-03-05 by check" - start_num
SEARCH("20??-??-??",A2)17 - num_chars
10
- text
DATEVALUE(MID(A2,SEARCH("20??-??-??",A2),10))3/5/2026 (46086)DATEVALUE: Converts date text to a date.- date_text
MID(A2,SEARCH("20??-??-??",A2),10)"2026-03-05"
- date_text
In Google Sheets
Google Sheets needs a different formula: =DATEVALUE(REGEXEXTRACT(A2,"\d{4}-\d{2}-\d{2}")). On the same data it gives the same result. Here it is running in Google Sheets mode.
Other ways to do it
Each one was run on the same example sheet.
| Formula | Result | When to use it |
|---|---|---|
| =DATEVALUE(REGEXEXTRACT(A2,"\d{4}-\d{2}-\d{2}"))Google Sheets | 3/5/2026, 4/18/2026, 5/2/2026… | 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}".
Try it yourself
Same data, empty answer cell. Your formula is graded instantly, then re-checked on changed data, so a typed-in number won't pass.
Extract a date from a text string
B2, pull the yyyy-mm-dd date out of the note and convert it to a real date. Fill down to B6.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.
Checked by running on 2026-10-30: every formula and result on this page was calculated by the Spreadsheet Practice formula engine, in both Excel and Google Sheets modes.