# How to convert a date to text in Excel

Use TEXT with a format code: =TEXT(A2,"yyyy-mm-dd") turns a date into text like 2026-03-04.

**Excel:** `=TEXT(A2,"yyyy-mm-dd")` (Every current version)

**Google Sheets:** the same formula works.

## Example

Sample data (row 1 is the header):

| A | B |
| --- | --- |
| Date | As text |
| 2026-03-04 |  |
| 2026-07-15 |  |
| 2026-11-30 |  |
| 2027-01-01 |  |
| 2026-09-09 |  |

Formula in B2, filled to B6: `=TEXT(A2,"yyyy-mm-dd")`

Result: 2026-03-04; 2026-07-15; 2026-11-30; 2027-01-01; 2026-09-09

## How it works

A date is stored as a number, and its format only changes how it looks. TEXT applies a format and returns the result as text, which keeps that exact form when you export, join or paste it. `yyyy` is the 4-digit year, `mm` the 2-digit month and `dd` the 2-digit day.

## Other ways

- `=YEAR(A2)&"-"&TEXT(MONTH(A2),"00")&"-"&TEXT(DAY(A2),"00")`: Builds the same text from the parts, without relying on date codes, which differ between languages.
- `=TEXT(A2,"mm/dd/yyyy")`: The US style. ("03/04/2026" instead of "2026-03-04".)

## Common mistakes

- `=A2&""` gives the serial number, "46085", not the date.
- The text can't be used in date math or sorted by date. Keep the real date in its own column.
- Format codes depend on the spreadsheet's language: a German Excel uses "JJJJ-MM-TT".
- Next to hours or seconds, mm means minutes. In a date pattern like "yyyy-mm-dd" it means the month.

## Questions

**How do I get text for a file name, like 20260304?**

Leave out the dashes: `=TEXT(A2,"yyyymmdd")`.

**How do I show the month and year only?**

Use `=TEXT(A2,"mmm yyyy")` for "Mar 2026".

**How do I turn the text back into a date?**

`=DATEVALUE(B2)`.

Every formula and result on this page was checked by running it in the Spreadsheet Practice formula engine on 2026-10-30.

Source: https://spreadsheetpractice.com/formulas/convert-a-date-to-text
