toString
Table of Contents
Overview
The toString function takes an expression as input and returns it as text.
Note:
- If the expression is of type date-time, you can specify two optional arguments, dateTimeFormat and timeZone, additionally. The function will return a DATE-TIME expression in the specified dateTimeFormat, converted into the specified time zone.
- If the expression is of type number (milliseconds), you can specify two optional arguments, dateTimeFormat and timeZone, additionally. The function will return a corresponding DATE-TIME expression in the specified dateTimeFormat, converted into the specified time zone. This is currently applicable to all Zoho services except Zoho Creator.
- In services other than Zoho Creator, you can either input expression of DATE-TIME datatype or a TEXT in date-time format in order for the dateTimeFormat and timeZone parameters to take action. However, in Zoho Creator, the input should strictly be an expression of DATE-TIME datatype, inputting a TEXT value in date-time format will simply return the given value as-is.
- In Zoho Creator, if the function fails to recognize the date-time value, it will simply return the given value in text format. In other services, an error message will be displayed.
- We are working on unifying the differences in behavior between Zoho Creator and other services.
Return Type
- TEXT
Syntax
<variable> = <expression>.toString(<dateTimeFormat>, <timeZone>);
(OR)
<variable> = toString(<expression>, <dateTimeFormat>, <timeZone>);
(OR)
<variable> = <expression>.toText(<dateTimeFormat>, <timeZone>);
(OR)
<variable> = toText(<expression>, <dateTimeFormat>, <timeZone>);
where,
Parameter | Data type | Description |
<variable> | TEXT | Variable which will contain the returned value. |
<expression> | ALL DATA TYPES | The expression which will be returned in text format. |
<dateTimeFormat> (optional) | TEXT | The format in which the date time value will be returned. Note:
|
<timeZone> (optional) | TEXT | Time zone in which the date-time value will be returned. 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 - Jan |
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
marks = 100; info toString(marks); // Returns 100
dateValue = '01-Jan-2019 10:15:30'; info toString(dateValue, "MMM dd, yy 'at' hh:mm:ss, E", "Europe/Moscow"); // Returns Jan 01, 19 at 07:45:30, Fri
milliValue = 1596719471334; info toString(milliValue, "MMM dd, yy 'at' hh:mm:ss, E", "Europe/Moscow"); // Returns Aug 06, 20 at 03:41:11, Thu