Asset 20 8 2
Does AI recommend your business? Run the free check →

Join 15,000 business owners, marketers and entrepreneurs. The Sunday newsletter you'll be annoyed only arrives once a week.

Article

How to Use the TEXT Function in Excel: Format Codes for Dates, Times, Percentages and Leading Zeros

The TEXT function in Excel changes the way a number looks by applying a format code to it, so =TEXT(0.285,"0.0%") shows 28.5% and =TEXT(TODAY(),"DDDD") shows the day of the week. The catch is in the name: the result is text, so Microsoft says to keep the original number in its own cell and build any other formulas from that, never from the TEXT result.

Microsoft describes TEXT as useful when you want numbers in a more readable format, or when you want to combine numbers with words or symbols. That second job is where it earns its place. For plain formatting, there's an easier way, which I'll come to.

TEXT syntax: a value and a format code in quotes

The syntax is TEXT(value, format_text). Both arguments are required:

ArgumentWhat it holds
valueThe number you want to convert to text, or the cell that holds it
format_textA format code, inside straight double quotes, that defines how the number should look

Leave the quotes off the format code and Excel shows an error. It's an easy one to miss when you're typing quickly.

Microsoft's TEXT examples and what they return

FormulaWhat it returns
=TEXT(0.285,"0.0%")28.5%
=TEXT(TODAY(),"MM/DD/YY")Today's date, such as 03/14/12
=TEXT(TODAY(),"DDDD")The day of the week, such as Monday
=TEXT(NOW(),"H:MM AM/PM")The current time, such as 1:29 PM
=TEXT(4.34,"# ?/?")The fraction 4 1/3
=TRIM(TEXT(0.34,"# ?/?"))1/3, with TRIM removing the leading space
=TEXT(12200000,"0.00E+00")1.22E+07 in scientific notation
=TEXT(12200000,"#,###")12,200,000 with thousands separators
=TEXT(12200000,"#,###.0,")12,200.0, scaled down by 1,000

The last two rows are worth a second look. A comma enclosed by number signs or zeros adds a separator, but a comma at the end, after the last # or 0, scales the number down by 1,000. Microsoft also points out that the separator itself depends on your regional settings: a comma in the US, a period in some other locales.

Microsoft's currency example puts a dollar sign in front of the code #,##0.00, so 1234.567 comes back as 1,234.57 with the symbol attached; Excel rounds to two decimal places. For any other currency, don't guess the code. Format Cells will show it to you, as below.

The mm catch: month or minutes?

This is the one that trips people up. Microsoft says "MM" or "mm" on its own returns the month. Put it next to hours or seconds and it returns minutes instead. Date codes in TEXT aren't case sensitive, so M and m, D and d, and Y and y all work the same.

Format codeWhat it gives you
"mm" on its ownThe month
"HH:MM"Hours and minutes
"MM:SS"Minutes and seconds
"H:MM AM/PM"Time on a 12-hour clock, such as 1:29 PM
"H:MM" with no AM/PMTime on a 24-hour clock

The rule behind it: M is for month, D for day and Y for year; H is for hours, M for minutes and S for seconds. If you leave out AM/PM or A/P, Excel shows the time on a 24-hour clock.

Leading zeros and dates: one example each

Excel looks for numbers, so it drops the leading zeros on part numbers and SKUs. =TEXT(1234,"0000000") puts them back and returns 0001234; the number of zeros in the code is the total number of characters you want. Better still, Microsoft suggests formatting the input range as Text before you paste or type the values. My guide to adding leading zeros in Excel covers every other method.

For dates, =TEXT(B2,"mm/dd/yy") turns the date in B2 into text in that pattern. If you only want a date column to look different, you don't need a formula at all; see how to change the date format in Excel.

How to find any format code without memorising it

  1. Select a cell and press Ctrl+1 (Cmd+1 on a Mac) to open Format Cells.
  2. On the Number tab, choose the format you want.
  3. Select Custom and copy the code shown in the Type box, leaving out any semicolon and @ symbol.
  4. Paste it into your TEXT formula, inside straight double quotes.

Two limits to know. TEXT doesn't support colour formatting, so a code you copy that includes a colour is accepted, but the colour won't display. And if all you want is a different look, Format Cells does it without a formula: currency format puts the symbol next to the value, while accounting format aligns the symbol left and the value right.

Work with me

Want AI doing the heavy lifting in your marketing?

I build the systems that handle the boring 80 percent, so you get your week back. Done properly, with the human kept in.

Turning the text back into a number

If you've already built on a TEXT result and the maths won't work, Microsoft gives two quick conversions: multiply it by 1, as in =D4*1, or use the double-unary operator, =--D4. Either one hands Excel a number again.

Writing a TEXT formula, step by step

  1. Keep the original number in its own cell.
  2. In another cell, type =TEXT(
  3. Point to the value, then type a comma.
  4. Type the format code in straight double quotes.
  5. Close the bracket and press Enter.

Where TEXT shines is joining a number to words, for example a label that reads Sales up 28.5% this month instead of 0.285. My guide to concatenating in Excel shows how to join the pieces together.

My take on TEXT

Reach for TEXT when a number has to sit inside a sentence, a label or a file name. For everything else, use Format Cells and leave the value alone. And never build a calculation on a TEXT result: it might look like 28.5%, but to Excel it's just words. Keep the original, point your formulas at it, and you won't get caught out.

Frequently asked questions

What does the TEXT function do in Excel?

It applies a format code to a number so it displays the way you want, and returns the result as text.

Why won't my TEXT result add up?

TEXT converts numbers to text. Keep the original value in another cell and build your calculations from that.

Why does mm show the month instead of minutes?

On its own mm means month. Next to hh or ss, as in HH:MM or MM:SS, it means minutes.

How do I find the right format code?

Press Ctrl+1, pick the format on the Number tab, choose Custom and copy the code from the Type box.

Can TEXT show a number in red?

No. Microsoft says TEXT doesn't support colour formatting, so a colour in the code won't display.

Published and maintained by the Lilach Bullock team, covering marketing, AI and business growth.
Your buyers are asking AI who to use. Does it say you?

See for free whether ChatGPT, Claude, Perplexity, Gemini and Google name you, and get the plan to become the answer.

Check my AI visibility →
Sundays only

Get the Sunday newsletter.

One email a week. AI experiments, marketing tactics, and the workflows Lilach is building right now in her own business.

Subscribe free

Let’s get your marketing running on AI.

Book a free 30-minute call

We figure out what you need, where AI fits in, and what working together would look like.

Book the call →

Or take the 30-second calculator

You’ll see the hours and the money quietly leaking out of your week, and the three workflows worth building first.

Take the calculator →

Or grab the free AI resource library

Prompt packs, templates, checklists, and swipe files. The exact tools I build for paying clients. Yours, free.

Get the library →
Keep reading

More from the blog.