Documentation/Calc Functions/TEXT

Function name:
TEXT

Category:
Text

Summary:
Converts a number into text, in a specified format.

The TEXT function is particularly useful when you want to embed a formatted number inside a text string.

Syntax:
TEXT(Number; Format)

Returns:
Returns a text string, which is the converted value in the required format.

Arguments:
Value is the value to be processed, or a reference to a cell containing that value. The supplied value may be in any numeric format that is valid for your locale, for example, a number in decimal notation, a number in scientific notation, a number in fraction notation, a percentage, a currency, a date, a time, or a Boolean.

Format is a text string (in quotation marks), or a reference to a cell containing a text string, that specifies the format for the output text string. For more information about this argument, see the section below.


 * If the Format string is not valid, TEXT reports an invalid argument error (Err:502).

Additional details:
To demonstrate the utility of the TEXT function, consider the following formula that was intended to show today's date:

Assuming that today is 2021-08-22, then this formula will display the string "Today's date is 44430", where 44430 is the date-time serial number for 2021-08-22. It is likely that this is not what the creator of the formula had in mind!

The following alternative formula uses the TEXT function and gives the output that was probably intended, with a properly formatted date:

This formula displays the string "Today's date is 2021-08-22".

Example format codes can be found on the Numbers tab of the Format Cells dialog, in the box labelled Format Code. Access this dialog using one of the following methods:


 * 1) Select  on the Menu bar.
 * 2) Right-click on a spreadsheet cell and select Format Cells on the context menu.
 * 3) Press the Ctrl+1 keyboard shortcut.

As you make selections in the Category, Format, Language, and Options areas of the Numbers tab, Calc updates the contents of the Format Code box to reflect those selections.

For a more detailed description, search for "number format codes" in the help index or visit the relevant help page.

The behavior of the TEXT function is locale-dependent, and therefore it should not be regarded as portable.

Examples:
The following examples assume that your locale is set to English (USA).

Related LibreOffice functions:
N

T

ODF standard:
Section 6.20.23, part 2

Equivalent Excel functions:
TEXT