← All how-to recipes

How to convert text to a real date

✓ Verified in LibreOffice 25.8.7.3 ✓ Verified in Google Sheets (2026-08-30)

Turn a date stored as text (like an import or CSV column) into a real date you can sort and calculate with.

The formula

AppFormulaNotes
Excel (desktop)=DATEVALUE(A2)Format the result cell as a date. Works when the text matches a recognized date format.
Google Sheets=DATEVALUE(A2)Identical.
LibreOffice Calc=DATEVALUE(A2)Identical.

How it works

DATEVALUE parses a text date into the date serial number spreadsheets use internally — "2026-07-21" becomes 46224 (days since the epoch). Format the cell as a date to display it normally; sorting and date arithmetic now work. ISO format (yyyy-mm-dd) parses reliably in all three apps; ambiguous formats like 07/03/2026 follow the spreadsheet's locale, which is the usual source of imported-date bugs.

Verified, not just documented

We ran =DATEVALUE(A2) in LibreOffice 25.8.7.3 (headless, with forced recalculation) and it returned 46224 — exactly the expected result. We then ran the same formulas in Google Sheets, executed 2026-08-30: a formula-only workbook goes into Google Drive, which converts it to a Sheet and recalculates every formula with Google’s own engine, and comes back out as .xlsx carrying the values Google computed. It returned 46224 for the worked example, the same value LibreOffice produced. Both engines’ numbers on this page are executed results. The Excel formula follows Microsoft’s official documented syntax — we do not run desktop Excel.

Functions used

DATEVALUE — see full Excel, Google Sheets & LibreOffice compatibility for each.

Related comparisons