Choose where you’d like to start

toString

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,

ParameterData typeDescription
<variable>TEXTVariable which will contain the returned value.
<expression>ALL DATA TYPESThe expression which will be returned in text format.

<dateTimeFormat>

(optional)

TEXT

The format in which the date time value will be returned.

Note:

  • Applicable only when the given expression is of date-time or number data type. The number type is currently supported in all services except Zoho Creator.
  • Within this param, you can only specify date-time literals which represent the respective components of a date or time value. Text can be quoted in single quotes to avoid interpretation. If any other value apart from date-time literals are specified without single quotes, the function will return null.
  • If this param is not specified, the date-time value will be returned in a format specified in application settings.

<timeZone>

(optional)

TEXT

Time zone in which the date-time value will be returned.

Note:

  • Applicable only when the given expression is of date-time data type. The number type is currently supported in all services except Zoho Creator.
  • Value must be specified exactly as given in the TZ database name.
  • If this param is not specified, the function will consider the time zone specified in application settings.

Applicable Date-Time Literals

LetterDate and Time Component
Era designator
y

Calendar year

Examples:

y - 2019

yy -19

yyy  - 2019

dateValue = '29-Dec-2019';
info dateValue.toString("yyyy"); // returns 2019

Y

Week year

Examples:

Y - 2019

YY -19

YYY  - 2019

dateValue = '29-Dec-2019';
info dateValue.toString("YYYY"); // returns 2020

M

Month in year

Examples:

M - 1

MM - 01

MMM - Jan

MMMM - January

wWeek in year
WWeek in month
DDay in year
dDay in month
FDay of week in month
E

Day name in week

Examples:

E - Tue

EEEE - Tuesday

uDay number of week
aam/pm marker
HHour in day (0-23)
kHour in day (1-24)
KHour in am/pm (0-11)
hHour in am/pm (1-12)
mMinute in hour
sSecond in minute
SMillisecond
zGeneral time zone
ZRFC time zone
XISO 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

Get Started Now

Execute