Spreadsheet Practice

How to convert a date to text in Excel

Formula (Excel and Google Sheets)

=TEXT(A2,"yyyy-mm-dd")

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

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

See it work

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

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.

=TEXT(A2,"yyyy-mm-dd")

Result"2026-03-04"

  1. A23/4/2026

    The value in A2.

  2. TEXT(A2,"yyyy-mm-dd")"2026-03-04"

    TEXT: Formats a number or date as text, e.g. "mmm" or "$#,##0".

    • valueA23/4/2026
    • format_text"yyyy-mm-dd"

In Google Sheets

The same formula works in Google Sheets: =TEXT(A2,"yyyy-mm-dd"). 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
=YEAR(A2)&"-"&TEXT(MONTH(A2),"00")&"-"&TEXT(DAY(A2),"00")2026-03-04, 2026-07-15, 2026-11-30…Builds the same text from the parts, without relying on date codes, which differ between languages.
=TEXT(A2,"mm/dd/yyyy")03/04/2026, 07/15/2026, 11/30/2026…Different resultThe 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.

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.

Convert a date to text

In B2, convert the date to text in the form yyyy-mm-dd and fill down to B6.

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).

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.