toString()
converts an integer, float or boolean value to a string.
Syntax: toString(expression)
Returns: A String.
Arguments
Name | Description |
expression | An expression that returns a number, a boolean, or a string. |
Example
RETURN toString(12)
The value returned will be a string after converting expression into it. In this example, toString will convert 12 to a string with the value “12”.
Note– 12 is not the same as “12”. 12 is an integer whereas “12” is a string.
Considerations
toString(null)
returnsnull
If
expression
is a string, it will be returned unchanged.
Example
RETURN toString(12.7)
Returns the following Result
toString(12.7) |
"12.7" |
Example
RETURN toString(FALSE)
Returns the following Result
toString(FALSE) |
"FALSE" |
Example
RETURN toString("I am a String!")
Returns the following Result
toString("I am a String!") |
"I am a String!" |
Example
RETURN toString(date({ year:1997, month:8, day:20 }))
Returns the following Result
toString(date({ year:1997, month:8, day:20 })) |
"1997-08-20" |
Example
RETURN toString(datetime({ year:1997, month:8, day:20, hour:7, minute:10, timezone: 'Asia/Kolkata' }))
Returns the following Result
toString(datetime({ year:1997, month:8, day:20, hour:7, minute:10, timezone: 'Asia/Kolkata' })) |
"1997-08-20T07:10:00+05:30[Asia/Kolkata]" |
Example
RETURN toString(duration({hour:7, minute:10}))
Returns the following Result
toString(duration({hours:7, minutes:10})) |
"PT7H10M" |
Note– toString can also convert Temporal(Date, Time, DateTime, LocalTime, etc. ) and Duration objects to strings.
Example
RETURN toString(null)
Returns the following Result
toString(null) |
null |
Note– toString(null)
returns null
.