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 toB7 - 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
A23/5/2026The value in A2.
ISNUMBER(A2)TRUEISNUMBER: TRUE if the value is a number.- value
A23/5/2026
- value
TRIM(A2)"46086"TRIM: Removes extra spaces, leaving single spaces between words.- text
A23/5/2026
- text
DATEVALUE(TRIM(A2))#VALUE!not usedDATEVALUE: Converts date text to a date.- date_text
TRIM(A2)"46086"
- date_text
IF(ISNUMBER(A2),A2,DATEVALUE(TRIM(A2)))46086IF: Returns one value if a test is true, another if false.- logical_test
ISNUMBER(A2)TRUE - value_if_true
A23/5/2026 - value_if_false
DATEVALUE(TRIM(A2))#VALUE!not used
- logical_test
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.
| Formula | Result | When 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 result | The 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!
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.