text
Table of Contents
Overview
The text function takes a numerical expression and returns it in the desired format.
Note:
- The function can format numbers, decimals and dates.
Return Type
- TEXT
Syntax
<variable> = <expression>.toText(<formatText>);
where,
| Parameter | Data type | Description |
| <variable> | TEXT | Variable which will contain the returned value. |
| <expression> | DATE-TIME / DECIMAL / NUMBER | The expression which needs to be formatted. |
<formatText> | TEXT | The text expression with which the desired expression needs to be formatted. Note:
|
Applicable Date-Time Literals
| Letter | Date and Time Component |
| G | Era designator |
| y | Calendar year Examples: y - 2019 yy -19 yyy - 2019 dateValue = '29-Dec-2019'; |
| Y | Week year Examples: Y - 2019 YY -19 YYY - 2019 dateValue = '29-Dec-2019'; |
| M | Month in year Examples: M - 1 MM - 01 MMM - January |
| w | Week in year |
| W | Week in month |
| D | Day in year |
| d | Day in month |
| F | Day of week in month |
| E | Day name in week Examples: E - Tue EEEE - Tuesday |
| u | Day number of week |
| a | am/pm marker |
| H | Hour in day (0-23) |
| k | Hour in day (1-24) |
| K | Hour in am/pm (0-11) |
| h | Hour in am/pm (1-12) |
| m | Minute in hour |
| s | Second in minute |
| S | Millisecond |
| z | General time zone |
| Z | RFC time zone |
| X | ISO 8601 time zone |
Examples
Below are the various ways in which date-time values, decimal and number values can be formatted.
leadingZero = 2434.text("000000000"); // 000002434 separateValue = "123123456".text("##,###"); // 123,123,456 dayOfYear = "02/04/2020".text("DDD"); // 035 monthOfYear = "02/04/2020".text("MM"); // 02 dayName = "02/04/2020".text("EEEE"); // Tuesday currencyFormat = "12345654.1234".text("$#,##0.00"); // $12,345,654.12 dateFormat = zoho.currenttime.text("MM/dd/YY"); // 02/04/20 dateFormat2 = zoho.currentdate.text("MMM dd, yy 'at' hh:mm:ss, E"); // Feb 04, 20 at 12:00:00, Tue noParam = zoho.currenttime.text(); // Run-time error: No. of arguments mismatches for the function text