Converts a number into text according to a specified format.
Examples
Sample Usage
TEXT(1.23,"$0.00")
TEXT(A2,"#.###")
TEXT(24,"#.0?")
TEXT(DATE(1969,7,20),"yyyy-MM")
Syntax
TEXT(number, format)
-
number- The number, date, or time to format. -
format- The pattern by which to format the number, enclosed in quotation marks.0forces display of zeros if a number has fewer digits than the format specifies. For example,TEXT(12.3,"000.00")produces012.30. Numbers which have more digits to the right of the decimal point than the pattern are rounded to the indicated number of places. For example,TEXT(12.305,"00.00")results in12.31.#is similar to0but does not force the display of zeros on either side of the decimal point. For example,TEXT(12.3,"###.##")produces12.3.
Notes
-
The
formatargument toTEXTcannot contain an asterisk (*). -
TEXTdoes not support the?pattern in Google Sheets. -
TEXTdoes not support fractional format patterns. -
TEXTsupports the following date and time patterns:dfor the day of the month as one or two digits.ddfor the day of the month as two digits.dddfor the short name of the day of the week.ddddfor the full name of the day of the week.mfor the month of the year as one or two digits or the number of minutes in a time. Month will be used unless this code is provided with hours or seconds as part of a time.mmfor the month of the year as two digits or the number of minutes in a time. Month will be used unless this code is provided with hours or seconds as part of a time.mmmfor the short name of the month of the year.mmmmfor the full name of the month of the year.mmmmmfor the first letter in the month of the year.yyfor the year as two digits.yyyyfor the year as four digits.HHfor the hour on a 24-hour clock.hhfor the hour on a 12-hour clock.ssfor the seconds in a time.ss.000for milliseconds in a time.AM/PMfor displaying hours based on a 12-hour clock and showing AM or PM depending on the time of day.
-
Note that the date/time patterns and
#or0cannot be mixed.
See Also
T: Returns string arguments as text.
FIXED: Formats a number with a fixed number of decimal places.
DOLLAR: Formats a number into the locale-specific currency format.