Templates, guides & honest tool reviews for small business

Sunday, November 29, 2026

TEXT Function in Excel: Format Dates, Numbers and Leading Zeros

TEXT function in Excel to format dates and numbers
Illustration: TEXT function in Excel

The TEXT function in Excel converts a number or a date into text with the format you choose. You use it to show a date as "Monday", to add leading zeros to a code or to put a formatted number inside a sentence. This guide shows the syntax and the most useful format codes with made-up examples, and explains the mistakes to avoid.

TEXT syntax

=TEXT(value, format_text)

The value is the number or date. The format_text is a format code in quotes. The result is always text, so you cannot add it up afterwards without converting it back.

Format dates

If A2 holds the date 5 November 2026:

  • =TEXT(A2, "dd/mm/yyyy") returns 05/11/2026.
  • =TEXT(A2, "d mmm yyyy") returns 5 Nov 2026.
  • =TEXT(A2, "mmmm") returns November.
  • =TEXT(A2, "dddd") returns Thursday.
  • =TEXT(A2, "yyyy-mm") returns 2026-11.

The code m gives the month number without a leading zero. In time formats, mm means minutes when it follows hours, and Excel decides by position.

TEXT function in Excel with date format codes like dddd and mmmm
Made-up date 5 Nov 2026 (illustration).

Format numbers

  • =TEXT(1234.5, "#,##0.00") returns 1,234.50.
  • =TEXT(1234.5, "0") returns 1235.
  • =TEXT(0.256, "0%") returns 26%.
  • =TEXT(0.256, "0.0%") returns 25.6%.

A zero in the code means "always show a digit here". A hash sign means "show a digit only if there is one".

TEXT function in Excel with number format codes for thousands and percent
Zero shows a digit, hash shows one if present (illustration).

Add leading zeros

To turn 7 into 007:

=TEXT(7, "000")

This is helpful for invoice numbers and product codes. The result is text, so keep it in a text column.

TEXT function in Excel to add leading zeros
Turn 7 into 007 (illustration).

Put a formatted value in a sentence

When you join numbers and words with the ampersand, Excel shows the raw number. Use TEXT to control the look:

="Total: " & TEXT(B2, "#,##0.00")

This returns something like Total: 1,234.50. The same method works for dates: ="Due on " & TEXT(C2, "d mmm yyyy"). For joining many cells, see our guide to the TEXTJOIN function.

TEXT function in Excel inside a sentence with a formatted total
Join words and formatted numbers (illustration).

Show a time

For a time in A2, =TEXT(A2, "hh:mm") returns a 24 hour time like 14:30, and =TEXT(A2, "h:mm AM/PM") returns 2:30 PM.

Use TEXT in a pivot table or a lookup key

You can build a month label such as 2026-11 with =TEXT(A2, "yyyy-mm") and use it in a pivot table. See how to group dates in an Excel pivot table for the alternative built-in method.

Language and region differences

Format codes depend on the language of your Excel. In some languages the letters for day, month and year are different, and the thousands and decimal separators may be a dot or a comma. If a format code does not work, check the codes your own version uses in Format Cells, under Custom.

Common mistakes

  • Missing quotes. The format code must be in quotation marks.
  • Using the result as a number. TEXT returns text. Wrap it in VALUE when you need math.
  • Wrong month code. mm is the month number with a leading zero, mmm is the short name and mmmm is the full name.
  • The date is text. TEXT cannot format a date that Excel does not recognize as one.

Questions and answers

What is the difference between TEXT and the Format Cells box?

Format Cells changes how a number looks and keeps it a number. TEXT creates a new text value.

Can I use TEXT in Google Sheets?

Yes. Many of the same codes work there.

How do I get the weekday name from a date?

Use =TEXT(A2, "dddd") for the full name or "ddd" for the short name.

How do I remove the leading zeros?

Use VALUE on the text, or multiply it by 1.

Summary

Write TEXT with a value and a quoted format code, remember that the result is text, and check the codes for your language if a result looks wrong.

العربية