Answers / Question 17
#VALUE! or wrong dates: fixing dates stored as text or read in the wrong locale (DD/MM vs MM/DD)
Why imported dates turn into text or swap day and month, why DATEVALUE returns #VALUE!, and formulas that rebuild real dates in Google Sheets and Excel.
The problem
You import a CSV or paste data from another system, and the dates misbehave. Subtracting two dates gives #VALUE!, sorting puts them in a strange order, and some dates look right while others are clearly wrong: 02/08/2026 shows up as February 8 when it meant 2 August. Changing the cell format to Date does nothing.
Inspired by a public question on Stack Overflow. The problem above is described in our own words and the solution below is ours.
Why it happens
A real date is stored as a number (a count of days) and only displayed as a date. When text such as 15/10/2026 arrives, the spreadsheet tries to read it using its own date order. Google Sheets uses the spreadsheet's locale; Excel uses your computer's regional settings. With a US setting (month first), 15/10/2026 can't be a date because there is no month 15, so it stays text. Worse, 02/08/2026 can be read month-first, so it quietly becomes the wrong real date. That's how one column ends up half text and half wrong.
Text can't be used in date maths, which is where #VALUE! comes from. Formatting doesn't convert text, so Format → Date changes nothing.
Step 1: find out what's actually in the cells
=ISNUMBER(A2)Text dates are usually left-aligned, real dates right-aligned. If a column mixes the two, assume the “real” ones may have day and month swapped.
Best fix: import again with the right date order
Google Sheets: open File → Settings and set Locale to one that writes dates day-first (for example United Kingdom), save, then import the file again with File → Import into this spreadsheet (insert a new sheet or replace the current one) and leave Convert text to numbers, dates, and formulas ticked. Changing the locale changes how new entries are read and how dates display; it doesn't repair cells that were already imported.
Excel: use Data → From Text/CSV, choose Transform Data, right-click the date column, pick Change Type → Using Locale, and choose Date with a day-first locale such as English (United Kingdom). For a column of text dates already in the sheet, select it and use Data → Text to Columns: choose Delimited, clear every delimiter, then under Column data format pick Date and DMY, and Finish.
Formula fix: rebuild the date from its parts
When you can't re-import, split the text into day, month and year and hand them to DATE(year, month, day), which doesn't depend on any locale. For text in the form DD/MM/YYYY:
=IF(A2="", "", LET(p, SPLIT(TRIM(A2), "/"), DATE(INDEX(p, 1, 3), INDEX(p, 1, 2), INDEX(p, 1, 1))))=IF(A2="", "", LET(p, --TEXTSPLIT(TRIM(A2), "/"), DATE(INDEX(p, 1, 3), INDEX(p, 1, 2), INDEX(p, 1, 1))))=DATE(VALUE(RIGHT(A2, 4)), VALUE(MID(A2, 4, 2)), VALUE(LEFT(A2, 2)))Format the result column as a date. When it looks right, copy it and paste it back as values only.
A column that's half text, half swapped
If every value really was DD/MM in the original file, the cells that became numbers were read month-first, so swap their day and month back, and rebuild the text ones as above:
=IF(A2="", "", IF(ISNUMBER(A2), DATE(YEAR(A2), DAY(A2), MONTH(A2)), LET(p, SPLIT(TRIM(A2), "/"), DATE(INDEX(p, 1, 3), INDEX(p, 1, 2), INDEX(p, 1, 1)))))=IF(A2="", "", IF(ISNUMBER(A2), DATE(YEAR(A2), DAY(A2), MONTH(A2)), LET(p, --TEXTSPLIT(TRIM(A2), "/"), DATE(INDEX(p, 1, 3), INDEX(p, 1, 2), INDEX(p, 1, 1)))))Only use the swap when you're sure about the source format. If some rows were typed in by hand correctly, it will break those.
Why DATEVALUE returns #VALUE!
DATEVALUE converts text to a date using the same locale rules, so it fails in two common ways: the text is in an order your settings don't recognize (DD/MM text under a US setting), or the cell already holds a real date. Both Google Sheets and Excel return #VALUE! when DATEVALUE is given a number. Check with ISNUMBER first; a real date doesn't need converting.
Good to know
- If the text includes a time, such as
15/10/2026 14:30, take the date part first:LEFT(A2, FIND(" ", A2&" ")-1)(Sheets or Excel) gives the text before the first space. - Two-digit years are risky:
DATEtreats 26 as 1926. Ask for four-digit years in exports, or add 2000 yourself. - If you control the export, choose ISO format (YYYY-MM-DD). Both apps read it the same way in any locale.
- In Sheets, some day-first locales also switch the formula separator from comma to semicolon. United Kingdom keeps commas.
- References: Google's DATEVALUE and locale settings help pages, and Microsoft's Convert dates stored as text to dates.
Formulas follow documented Google Sheets / Excel behavior; they aren't machine-tested, so try them on a copy first. Always try new automations on a copy of your sheet first.