How to use the TEXT function in Excel: format numbers and dates as text
TEXT converts a number, date or time into text in the format you choose: 1,250,000, 15%, 15.03.2025, March. Essential when joining numbers with text.
Syntax
=TEXT(value, "format_text")
- value — The number, date, time or cell containing one that you want to format.
- format_text — A format code in quotes: "#,##0", "0.00", "0%", "dd.mm.yyyy", "mmmm", "hh:mm" and so on.
Example
Formula:
="Discount: "&TEXT(B2,"0%")→ result: Discount: 15%
Why you need TEXT
Cell formatting (Ctrl+1) only changes how a value looks; the value itself stays the same. When you join a number to text with &, the formatting is lost: even if B2 shows 15%, ="Discount: "&B2 returns “Discount: 0.15”. TEXT solves this: it first turns the number into text with the look you want, and then you can join it with anything. In the example ="Discount: "&TEXT(B2,"0%") → “Discount: 15%”.
Number format codes
• "0" — round to a whole number: 1250.7 → 1251 • "0.00" — two decimals: 3.5 → 3.50 • "#,##0" — thousands separator: 1250000 → 1,250,000 • "#,##0.00" — separator and two decimals: 1,250,000.00 • "0%" and "0.0%" — percentage: 0.156 → 16% or 15.6% • "00000" — leading zeros: 42 → 00042 (for codes, IDs, postcodes) • "#,##0,," — in millions: 1250000 → 1 (each trailing comma divides by a thousand) 0 is a required digit (shows 0 if there is none); # shows a digit only if it exists.
Date and time format codes
If A2 contains 15 March 2025 14:30: • "dd.mm.yyyy" → 15.03.2025, "mm/dd/yyyy" → 03/15/2025 • "d mmmm yyyy" → 15 March 2025 • "mmmm" → March, "mmm" → Mar • "dddd" → Saturday, "ddd" → Sat • "yyyy" → 2025 • "hh:mm" → 14:30, "hh:mm:ss" → 14:30:00, "h:mm AM/PM" → 2:30 PM Note: "mm" next to hours means minutes; otherwise it means the month. Month and day names appear in Excel’s language.
Joining text, numbers and dates
The most useful pattern for report titles and automatic messages: ="Total sales: "&TEXT(B10,"#,##0")&" UZS" → Total sales: 1,250,000 UZS ="Report date: "&TEXT(A2,"dd.mm.yyyy") → Report date: 15.03.2025 =TEXT(A2,"dd.mm.yyyy")&" — "&TEXT(A2,"dddd") → date and weekday If you join a date to text without TEXT, you get its serial number instead: “Report date: 45731”.
Format codes depend on Excel’s language
The code inside TEXT depends on Excel’s language and Windows regional settings. In Russian Excel, date codes use Cyrillic letters: "ДД.ММ.ГГГГ" instead of "dd.mm.yyyy", "ММММ" for the month name and "чч:мм" for time. Number codes follow the regional separators — with Russian or Uzbek settings the thousands separator is usually a space and the decimal mark a comma: "# ##0,00". A code written for another language gives wrong results. If a workbook is opened on computers with different languages, prefer cell formatting (Ctrl+1) over TEXT where you can. Codes like "0%" and "00000" work the same everywhere.
Common errors
• TEXT returns text. SUM won’t add it (you get 0) and sorting becomes alphabetical. Keep the original numeric column for calculations and use TEXT only for display. • The format code has no quotes: not TEXT(B2,0%) but TEXT(B2,"0%"). • Minutes appear instead of the month — "mm" next to "hh" means minutes; use "mmm" or "mmmm" when the month sits next to a time. • A strange number or the code itself appears instead of a date — the code doesn’t match Excel’s language (see the section above).
Pro tips
• Turn text back into a number: =VALUE(A2) or =--A2. • Weekday reports: put =TEXT(A2,"dddd") in a helper column and analyze it with COUNTIF or a PivotTable. • Show a month name in another language: =TEXT(A2,"[$-419]mmmm") gives Russian, "[$-409]mmmm" gives English. • If you only need the look, type the same code in Ctrl+1 → Custom: the value stays a number and still works in calculations.
Has ExcelLab been useful?
Support the project and help us release new lessons and exercises.