When you enter your query in the SQL Editor or create a calculation, you use Presto SQL syntax. To convert or return the data type of a value or expression, you may find these functions useful.
CAST or TRY_CAST
To convert a field's value to another data type, use the CAST
function as CAST(value AS type). For example, to convert a Month field's value from numerical text to an integer as part of a calculation, CAST({1} AS integer)
.
If the conversion fails, CAST
returns an error. To return NULL
instead of an error if the conversion fails, use the TRY_CAST
function as TRY_CAST(value AS type).
Note: To convert a value to a date, use the DATE
date and time function.
TYPEOF
To return the data type of an expression, use the TYPEOF
function as TYPEOF(expression). For example, SELECT TYPEOF(123)
results in integer.