Spreadsheet Practice

How to fix DATEVALUE returning #VALUE! in Excel

Formula (Excel and Google Sheets)

=IF(ISNUMBER(A2),A2,DATEVALUE(TRIM(A2)))

Pass real dates through and clean the text before converting: =IF(ISNUMBER(A2),A2,DATEVALUE(TRIM(A2))).

Result on the example
one result per row in B2, filled down to B7
Works in
Every current version
Google Sheets
Same formula

See it work

The formula is already in B2, filled down to B7. Change any input and the result updates, or edit the formula to experiment.

How it works

DATEVALUE only accepts text. A cell that already holds a real date is a number, so DATEVALUE rejects it with #VALUE!, and text with stray spaces can fail too. ISNUMBER passes real dates through untouched, and TRIM cleans the text before DATEVALUE reads it.

=IF(ISNUMBER(A2),A2,DATEVALUE(TRIM(A2)))

Result46086

  1. A23/5/2026

    The value in A2.

  2. ISNUMBER(A2)TRUE

    ISNUMBER: TRUE if the value is a number.

    • valueA23/5/2026
  3. TRIM(A2)"46086"

    TRIM: Removes extra spaces, leaving single spaces between words.

    • textA23/5/2026
  4. DATEVALUE(TRIM(A2))#VALUE!not used

    DATEVALUE: Converts date text to a date.

    • date_textTRIM(A2)"46086"
  5. IF(ISNUMBER(A2),A2,DATEVALUE(TRIM(A2)))46086

    IF: Returns one value if a test is true, another if false.

    • logical_testISNUMBER(A2)TRUE
    • value_if_trueA23/5/2026
    • value_if_falseDATEVALUE(TRIM(A2))#VALUE!not used

In Google Sheets

The same formula works in Google Sheets: =IF(ISNUMBER(A2),A2,DATEVALUE(TRIM(A2))). We ran it in Google Sheets mode on the same data and it returns the same results.

Other ways to do it

Each one was run on the same example sheet.

FormulaResultWhen to use it
=IFERROR(DATEVALUE(TRIM(A2)),A2)3/5/2026, 3/9/2026, 3/12/2026…Tries the conversion and falls back to the cell itself when it is already a date.
=DATEVALUE(A2)#VALUE!, 3/9/2026, 3/12/2026…Different resultThe formula that fails: #VALUE! on the real dates. Errors on the cells that are already dates.

Common mistakes

  • Text in a different regional order, like "20/03/2026" on US settings, still returns #VALUE!. Rebuild it with DATE.
  • Non-breaking spaces from web pages survive TRIM. Remove them first with SUBSTITUTE(A2,CHAR(160),"").

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.

Fix DATEVALUE returning #VALUE!

In B2, return a real date for every row: keep cells that are already dates, and convert text dates (some with extra spaces). Fill down to B7.

Questions

How do I tell real dates from text dates?

=ISNUMBER(A2) is TRUE for real dates. Text dates are usually left-aligned in the cell.

Why does DATEVALUE give a five-digit number?

That number is the date. Format the cell as a date.

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.