Text | STRING

Syntax

STRING( [input], [default = ""] )

Parameters

input
Any data may be used as the input.

default optional
If input cannot be converted to a text value, default is returned. default may be any value.

Return Value

The result of the input being converted to a text format.

Description

Where possible, any value passed into this method will return as text. The default value is used if the input cannot be converted to a string. The default value will be returned if the input is NULL, is an object, or is an invalidly formatted date. When the input is an array of values a string is returned where each array value is stringified and delimited by a comma. Date values are returned in ISO format. The default value is never modified and is always used as-is.

Examples

STRING(1) # returns "1"
STRING(true) # returns "true"
STRING(null) # returns ""
STRING(undefined) # returns ""
STRING(null, null) # returns NULL
STRING(CURRENT_DATE()) # returns "2020-07-24T23:59:35.960Z"
STRING([1, 2, 3]) # returns "1,2,3"
STRING([1, 2, false]) # returns "1,2,false"
STRING([1, null, 3]) # returns "1,,3"