TO_INT
Description
TO_INT
is a row function that converts TEXT
, BOOLEAN
, INTEGER
, LONG
, or DOUBLE
values to INTEGER
(whole number) values. When converting DOUBLE
values, everything after the decimal will be truncated (not rounded up or down).Syntax
TO_INT
(expression
)Return Value
Returns one value per row of type
INTEGER
.Input Parameters
- expression
- Required. A field or expression of typeTEXT,BOOLEAN,INTEGER,LONG, orDOUBLE. If aTEXTfield contains non-numeric characters, the function returns NULL.
Examples
Convert the values of the
average_rating
field to an Integer field type:TO_INT([average_rating])
Convert the
flight_duration
field to an Integer field type, but first transform the occurrence of any NA
values to NULL values using a CASE
expression:TO_INT(CASE WHEN [flight_duration]="N/A" then NULL ELSE [flight_duration] END)