Skip to main content
Version: 2.15.X

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

CategoryDetails
Number of Arguments1+
Mandatory Argument Names and Datatypesarg: Any datatype.
  • Scalar Support: True
  • Array Support: True
  • Group of Scalars Support: True
  • Group of Arrays Support: True
Optional Argument Names and DatatypesN/A
ModifiersN/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

CategoryDetails
Number of Arguments1
Mandatory Argument Names and Datatypesarg: An integer, float, or string. Strings are case-insensitive.
  • Scalar Support: True
  • Array Support: True
  • Group of Scalars Support: True
  • Group of Arrays Support: True
Optional Argument Names and DatatypesN/A
ModifiersN/A
Output Datatype(s)Boolean

The supported (case-insensitive) string inputs and their evaluations are as follows:

TrueFalse
TrueFalse
TF
OnOff
YesNo
YN

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 inputs into datetime format.

Usage Information

CategoryDetails
Number of Arguments2
Mandatory Argument Names and Datatypes
  • arg: A string or integer to convert.
  • format: A string indicating the format of the input.
  • Scalar Support: True
  • Array Support: True
  • Group of Scalars Support: True
  • Group of Arrays Support: True
Optional Argument Names and DatatypesN/A
ModifiersN/A
Output Datatype(s)Datetime

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("2020-02-01T02:00:00.200-08:00") ==> "2020-02-01T02:00:00.200-08:00"
toDatetime("2020-02-01T15:30:00.200+05:30") ==> "2020-02-01T15:30:00.200+05:30"
toDatetime(1663690995000) ==> "2022-09-23T21:35:37.000Z"

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 Epoch

The To Epoch function converts a datetime input to an epoch representation of time.

Usage Information

CategoryDetails
Number of Arguments1
Mandatory Argument Names and Datatypesarg: A datetime to convert.
  • Scalar Support: True
  • Array Support: True
  • Group of Scalars Support: True
  • Group of Arrays Support: True
Optional Argument Names and DatatypesN/A
ModifiersN/A
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

CategoryDetails
Number of Arguments1
Mandatory Argument Names and Datatypesarg: An integer or string to convert.
  • Scalar Support: True
  • Array Support: True
  • Group of Scalars Support: True
  • Group of Arrays Support: True
Optional Argument Names and DatatypesN/A
ModifiersN/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

CategoryDetails
Number of Arguments1
Mandatory Argument Names and Datatypesarg: A float or string to convert.
  • Scalar Support: True
  • Array Support: True
  • Group of Scalars Support: True
  • Group of Arrays Support: True
Optional Argument Names and DatatypesN/A
ModifiersN/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}
warning

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

CategoryDetails
Number of Arguments1
Mandatory Argument Names and Datatypesarg: A string to convert.
  • Scalar Support: True
  • Array Support: True
  • Group of Scalars Support: True
  • Group of Arrays Support: True
Optional Argument Names and DatatypesN/A
ModifiersN/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

CategoryDetails
Number of Arguments1
Mandatory Argument Names and Datatypesarg: The input to convert. It can be any datatype.
  • Scalar Support: True
  • Array Support: True
  • Group of Scalars Support: True
  • Group of Arrays Support: True
Optional Argument Names and Datatypesdatetime_format: A string specifying the datetime format to use.
ModifiersN/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

CategoryDetails
Number of Arguments1
Mandatory Argument Names and Datatypesarg: A string to convert.
  • Scalar Support: True
  • Array Support: True
  • Group of Scalars Support: True
  • Group of Arrays Support: True
Optional Argument Names and DatatypesN/A
ModifiersN/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"]}