ShareYourGroupShareYourGroupExcel Formulas

Text functions

TEXT function in Excel

TEXT turns a number or date into text in the format you choose.

A cell's number format changes how a value looks while keeping it a number. TEXT does something different: it produces a piece of text that looks the way you want. You need it whenever a number or date goes inside a sentence, a label or a joined code, because joining strips the formatting away.

Syntax

=TEXT(value, format_text)
ArgumentWhat it is
valueThe number or date to format.
format_textA format code in quotation marks, such as "0.00", "#,##0" or "dd-mmm-yyyy".

Examples

Each result below is what Excel itself showed for the formula on the sample sheet.

Sample sheet: Twelve sales made by four salespeople in three regions.
ABCDEF
1DateSalespersonRegionProductUnitsAmount
205-Jan-2026AshaNorthNotebook201200
312-Jan-2026RaviSouthPen50500
420-Jan-2026MeenaNorthBag43000
502-Feb-2026AshaEastPen30300
614-Feb-2026KabirSouthNotebook15900
728-Feb-2026RaviNorthBag21500
803-Mar-2026MeenaEastNotebook402400
915-Mar-2026AshaNorthBag32250
1022-Mar-2026KabirSouthPen60600
1101-Apr-2026RaviEastNotebook251500
1218-Apr-2026MeenaNorthPen80800
1306-May-2026AshaSouthBag53750

How it works

TEXT takes a value and a format code and returns the value written out in that format. The codes are the same ones used in Format Cells, under Custom, so any format you can build there can be given to TEXT.

Format codes for numbers

Code1234.5 becomesMeaning
"0"1235whole number
"0.00"1234.50two decimals, always shown
"#,##0"1,235thousands separator
"#,##0.00"1,234.50separator and two decimals
"0.0%"123450.0%percentage (the value is multiplied by 100)
"00000"01235padded with zeros to five digits

0 shows a digit always, with a zero if there is none. # shows a digit only when there is one.

The comma separator follows the international pattern, in groups of three. For the Indian pattern of lakhs and crores, a custom format such as "[>=10000000]##\,##\,##\,##0;[>=100000]##\,##\,##0;##,##0" is commonly used.

Format codes for dates

CodeGivesExample
dday5
ddday, two digits05
dddshort day nameMon
ddddfull day nameMonday
mmonth number1
mmmonth, two digits01
mmmshort month nameJan
mmmmfull month nameJanuary
yyyear, two digits26
yyyyyear, four digits2026
h:mm AM/PMtime on a 12-hour clock6:30 PM

Combine them freely with spaces, dashes and slashes: "dd/mm/yyyy", "d mmmm yyyy", "ddd, d mmm".

The result is text

This is the point to remember. The output of TEXT cannot be added, averaged or compared as a number. =TEXT(A1,"0.00")+1 happens to work because Excel converts it back, but SUM over a column of TEXT results gives 0, and sorting them sorts as text, where "100" comes before "20".

So:

Useful patterns

Regional settings

Date codes depend on the language of the computer. On a system set to German, the year code is j, not y. A workbook that uses TEXT with date codes may show odd results on a computer with different regional settings. Number codes are more portable, though the decimal and thousands characters also follow the system.

Common mistakes

In Google Sheets

TEXT works the same way in Google Sheets, with the same codes for the common cases.

Related functions

Every result on this page was calculated in Microsoft Excel (version 16.0, build 20326) on 12 November 2026, not typed by hand.

This is an independent help site. It is not connected with or approved by Microsoft. Excel and Microsoft 365 are trademarks of Microsoft Corporation, named here only to say which program a formula is for. The people and figures in the sample sheets are made up.