Datatype Conversions
Datatype conversion functions provide mechanisms to convert data of a given type into a different type.
The examples for each function use the following notation:
- Square brackets (
[]) indicate arrays. - Curly braces (
{}) indicate groups. - Arrows (
==>) separate inputs and outputs. Inputs are shown on the left side of the arrow. Outputs are shown on the right side of the arrow.
To Array
The To Array function converts its input to an array. Any set-of-array inputs are automatically flattened.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1+ |
| Mandatory Argument Names and Datatypes | arg: Any datatype.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | N/A |
| Output Datatype(s) | An array matching the input datatype. |
Examples
toArray("ABC") ==> ["ABC"]
toArray(1,2,3) ==> [1,2,3]
toArray([1,2,3]) ==> [1,2,3]
toArray({1,2,3}) ==> [1,2,3]
toArray({[1,2,3],[4,5,6],[7,8]}) ==> [1,2,3,4,5,6,7,8]
To Boolean
The To Boolean function converts its input to a Boolean value.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 |
| Mandatory Argument Names and Datatypes | arg: An integer, float, or string. Strings are case-insensitive.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | N/A |
| Output Datatype(s) | Boolean |
The supported (case-insensitive) string inputs and their evaluations are as follows:
| True | False |
|---|---|
| True | False |
| T | F |
| On | Off |
| Yes | No |
| Y | N |
Examples
toBoolean("T") ==> True
toBoolean("Off") ==> False
toBoolean("Not a boolean string") ==> null
toBoolean(1) ==> True
toBoolean(-1) ==> True
toBoolean(0) ==> False
toBoolean(["Y","F","Hello"]) ==> [True,False,null]
toBoolean({"Y","Off","Yes"}) ==> {True,False,True}
toBoolean({[1,0,1],[0,0,0],[1,1,1]} ==> {[True,False,True],[False,False,False],[True,True,True]})
To Datetime
The To Datetime function converts the input string or epoch representation of time into a datetime with timezone datatype.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 2 |
| Mandatory Argument Names and Datatypes |
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | N/A |
| Output Datatype(s) | Datetime with Timezone |
Note
- If the input is not in a valid ISO format, the output will be converted to Zulu time (i.e.,
yyyy-MM-ddTHH:mm:ss[.SSS]Z).- If the input is in ISO format and contains a timezone value, the format and timezone value will be preserved.
Examples
Dates in the following format do not require a format string:
toDatetime("2020-10-01T10:00:00Z") ==> "2020-10-01T10:00:00.000Z"
toDatetime("2020-10-01T10:00:00.200Z") ==> "2020-10-01T10:00:00.200Z"
toDateTime(1755115064, unit=s) ==> 2025-08-13T12:57:44.000Z
toDateTime(1755115064000, unit=ms) ==> 2025-08-13T12:57:44.000Z
toDateTime("13/8/2025 12:57:44 -0800", format="d/M/y HH:mm:ss X") ==> "2025-08-13T12:57:44.000 -0800"
Anything else requires a format string:
toDatetime("10/1/2020 10:17:46.384",format="dd/MM/yyyy HH:mm:ss.SSS") ==> "2020-01-10T20:17:46.384Z"
To use timezone offsets, use the X timezone indicator:
toDatetime("10/1/2020 10:17:46.384-08:00",format="dd/MM/yyyy HH:mm:ss.SSSX") ==> "2020-10-01T18:17:46.384Z"
To use timezone abbreviation, use the Z timezone indicator:
toDatetime("10/1/2020 10:17:46.384PDT",format="dd/MM/yyyy HH:mm:ss.SSSZ") ==> "2020-10-01T18:17:46.384Z"
Array and group examples:
toDatetime(["10/1/2020 10:17:46.384","10/1/2020 10:17:47.384","10/1/2020 10:17:48.384"], "dd/MM/YYYY HH:mm:ss.SSS") ==> ["2020-01-10T20:17:46.384Z","2020-01-10T20:17:47.384Z","2020-01-10T20:17:48.384Z"]
toDatetime({"10/1/2020 10:17:46.384","10/1/2020 10:17:47.384","10/1/2020 10:17:48.384"}, "dd/MM/YYYY HH:mm:ss.SSS") ==> {"2020-01-10T20:17:46.384Z","2020-01-10T20:17:47.384Z","2020-01-10T20:17:48.384Z"}
To Datetime Without Timezone
The To Datetime Without Timezone function converts the input string representation of time into a datetime without timezone datatype.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 or 2 |
| Mandatory Argument Names and Datatypes | arg: A string to convert.
|
| Optional Argument Names and Datatypes | format: A string indicating the format of the input.
|
| Modifiers | N/A |
| Output Datatype(s) | Datetime without Timezone |
Examples
toDateTimeWithoutTimezone("13/8/2025 12:57:44", format="d/M/y HH:mm:ss") ==> "2025-08-13T12:57:44.000"
To Epoch
The To Epoch function converts a datetime with timezone input to an epoch representation of time.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 |
| Mandatory Argument Names and Datatypes | arg: A datetime with timezone to convert.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers |
|
| Output Datatype(s) | Integer |
Examples
toEpoch("2022-09-23T21:35:37.000Z") ==> 1663968937000
toEpoch(["2022-09-23T21:35:37.000Z","2022-09-23T21:35:37.000Z","2022-09-23T21:35:37.000Z"]) ==> [1663968937000,1663968937000,1663968937000]
toEpoch({"2022-09-23T21:35:37.000Z","2022-09-23T21:35:37.000Z","2022-09-23T21:35:37.000Z"}) ==> {1663968937000,1663968937000,1663968937000}
toEpoch({["2022-09-23T21:35:37.000Z","2022-09-23T21:35:37.000Z"],["2022-09-23T21:35:37.000Z","2022-09-23T21:35:37.000Z"],["2022-09-23T21:35:37.000Z","2022-09-23T21:35:37.000Z"]}) ==> {[1663968937000,1663968937000],[1663968937000,1663968937000],[1663968937000,1663968937000]}
To Float
The To Float function converts integers or strings to floating-point decimal numbers.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 |
| Mandatory Argument Names and Datatypes | arg: An integer or string to convert.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | N/A |
| Output Datatype(s) | Float |
Examples
toFloat(1) ==> 1.0
toFloat("200.1") ==> 200.1
toFloat("hello world") ==> null
toFloat([3,2,1]) ==> [3.0,2.0,1.0]
toFloat({3,2,1}) ==> {3.0,2.0,1.0}
toFloat({"3.1","2.1","hello"}) ==> {3.1,2.1,null}
toFloat({[3,2,1],[6,5,4],[9,8,7]}) ==> {[3.0,2.0,1.0],[6.0,5.0,4.0],[9.0,8.0,7.0]}
To Integer
The To Integer function converts floating point numbers or strings to integers.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 |
| Mandatory Argument Names and Datatypes | arg: A float or string to convert.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | N/A |
| Output Datatype(s) | Integer |
Examples
toInt(1.7) ==> 1
toInt("6") ==> 6
toInt([3.14,2.06,7.99]) ==> [3,2,7]
toInt({3.14,2.06,7.99}) ==> {3,2,7}
toInt({[3.0,2.0,1.0],[6.0,5.0,4.0],[9.0,8.0,7.0]}) ==> {[3,2,1],[6,5,4],[9,8,7]}
toInt({"1","2","3.6"}) ==> {1,2,3}
The following is an invalid use of To Integer:
toInt("6.24") ==> 6
To IP
The To IP function converts a string to an IP.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 |
| Mandatory Argument Names and Datatypes | arg: A string to convert.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | N/A |
| Output Datatype(s) | IP |
Examples
toIp("127.0.0.1") ==> 127.0.0.1
toIp("127.0.0.1/16") ==> 127.0.0.1/16
toIp("abc") ==> null
toIp(["127.0.0.1","2001:0db8:85a3:0000:0000:8a2e:0370:7334","abc"]) ==> [127.0.0.1, 2001:0db8:85a3::8a2e:0370:7334,null]
toIp({"127.0.0.1/8","2001:0db8:85a3:0000:0000:8a2e:0370:7334/24","abc"}) ==> {127.0.0.1/8, 2001:0db8:85a3::8a2e:0370:7334/24,null}
toIp({["127.0.0.1/8","2001:0db8:85a3:0000:0000:8a2e:0370:7334/24","abc"]}) ==> {[127.0.0.1/8, 2001:0db8:85a3::8a2e:0370:7334/24,null]}
To String
The To String function converts its input to a string.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 |
| Mandatory Argument Names and Datatypes | arg: The input to convert. It can be any datatype.
|
| Optional Argument Names and Datatypes | datetime_format: A string specifying the datetime format to use. |
| Modifiers | N/A |
| Output Datatype(s) | String |
Examples
toString(10) ==> "10"
toString(3.14) ==> "3.14"
toString(True) ==> "True"
toString(127.0.0.1) ==> "127.0.0.1"
toString("2020-01-10T20:17:46.384Z") ==> "2020-01-10T20:17:46.384Z"
toString("2020-01-10T20:17:46.384Z", datetime_format="dd/MM/yyyy HH:mm:ss.SSS") ==> "10/01/2022 20:17:46.384"
toString("3bfebee5-c780-41c1-82ed-0ec75d54d1f0") ==> "3bfebee5-c780-41c1-82ed-0ec75d54d1f0"
toString("https://www.google.com") ==> "https://www.google.com"
toString(geo-json) ==> "{geo-json}"
toString({1,2,3}) ==> {"1","2","3"}
toString([1,2,3]) ==> "[1,2,3]"
toString({[1,2,3],[1,2,3],[1,2,3]}) ==> {"[]","[]","[]"}
To URL
The To URL function converts its input to a URL. The protocol for the URL defaults to http:// if not provided.
Usage Information
| Category | Details |
|---|---|
| Number of Arguments | 1 |
| Mandatory Argument Names and Datatypes | arg: A string to convert.
|
| Optional Argument Names and Datatypes | N/A |
| Modifiers | N/A |
| Output Datatype(s) | URL |
Examples
toUrl("google.com") ==> "http://google.com"
toUrl(["google.com","amazon.com","twitter.com"]) ==> ["http://google.com","http://amazon.com","http://twitter.com"]
toUrl({"google.com","amazon.com","twitter.com"}) ==> {"http://google.com","http://amazon.com","http://twitter.com"}
toUrl({["google.com","amazon.com","twitter.com"],["facebook.com","instagram.com","tiktok.com"],["cogility.com","tacitred.com","cogynt.com"]}) ==> {["http://google.com","http://amazon.com","http://twitter.com"],["http://facebook.com","http://instagram.com","http://tiktok.com"],["http://cogility.com","http://tacitred.com","http://cogynt.com"]}