Choose where you’d like to start

toText

Note: This task is applicable to all services except Zoho Creator

Overview

The toText function takes an expression, and returns it as text.

Note:

  • If the expression is of type date-time or number (milliseconds), you can specify two optional arguments, dateTimeFormat and timeZone, additionally.
  • The function will return the timestamp expression in the specified dateTimeFormat, converted into the specified timeZone.
  • If the function fails to recognise the date-time value, it will simply return the given value in text format.

Return Type

  • TEXT

Syntax

<variable> = <expression>.toText(<dateTimeFormat>, <timeZone>);

(OR)

<variable> = toText(<expression>, <dateTimeFormat>, <timeZone>);

(OR)​

<variable> = <expression>.toString(<dateTimeFormat>, <timeZone>);

(OR)

<variable> = toString(<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 (milliseconds) data type.
  • 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 or number (milliseconds) data type.
  • 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.toText("yyyy"); // returns 2019

Y

Week year

Examples:

Y - 2019

YY -19

YYY  - 2019

dateValue = '29-Dec-2019';
info dateValue.toText("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 toText(marks); // returns "100"
 marks = 100;
 info toText(marks); // returns "100"
 dateValue = '01-Jan-2019 10:15:30';
 info toText(dateValue, "MMM dd, yy 'at' hh:mm:ss, E", "Europe/Moscow"); // returns "Jan 01, 19 at 07:45:30, Fri"
 milliValue = 1596719471334;
 info toText(milliValue, "MMM dd, yy 'at' hh:mm:ss, E", "Europe/Moscow"); 
 // Returns "Aug 06, 20 at 03:41:11, Thu"

Get Started Now

Execute