Spreadsheet Practice

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 to B6
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)

  1. A2"Paid in full on 2026-03-05 by check"

    The value in A2.

  2. SEARCH("20??-??-??",A2)17

    SEARCH: Position of text, not case-sensitive, allows wildcards.

    • find_text"20??-??-??"
    • within_textA2"Paid in full on 2026-03-05 by check"
  3. MID(A2,SEARCH("20??-??-??",A2),10)"2026-03-05"

    MID: Characters from the middle of text.

    • textA2"Paid in full on 2026-03-05 by check"
    • start_numSEARCH("20??-??-??",A2)17
    • num_chars10
  4. DATEVALUE(MID(A2,SEARCH("20??-??-??",A2),10))3/5/2026 (46086)

    DATEVALUE: Converts date text to a date.

    • date_textMID(A2,SEARCH("20??-??-??",A2),10)"2026-03-05"

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.

FormulaResultWhen to use it
=DATEVALUE(REGEXEXTRACT(A2,"\d{4}-\d{2}-\d{2}"))Google Sheets3/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

In 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.