Type Conversion

type conversion functions

The following functions convert values between types:

  • int, int64: Converts to integer.
  • float, double: Converts to double.
  • string: Converts to string.
  • bool: Converts to boolean.
  • guid: Converts to GUID.
  • json: Converts to JSON. See json for details on property access.

Spec

int(arg0)
int64(arg0)
float(arg0)
double(arg0)
string(arg0)
bool(arg0)
guid(arg0)
json(arg0)

Parameters

arg0 - The value to convert.

Return Value

The converted value in the target type.

Example

Convert string to int:

datatable(s:string)["123", "456"]
| extend num = int(s)
snum
123123
456456

Convert int to string:

datatable(val:int64)[1, 2]
| extend str_val = string(val)
valstr_val
1"1"
2"2"

Convert string to bool:

datatable(s:string)["true", "false"]
| extend b = bool(s)
sb
truetrue
falsefalse

Convert string to GUID:

datatable(s:string)["b2e1975b-677c-4ac6-a0ed-e63acb67ff09"]
| extend id = guid(s)
sid
b2e1975b-677c-4ac6-a0ed-e63acb67ff09b2e1975b-677c-4ac6-a0ed-e63acb67ff09