Documentation

    CAST

    Convert a value to another data type; invalid conversions raise an error.

    Try an expression

    In Formula, enter the expression and set Output type to VARCHAR.

    Example input

    1. Row 1amount = 20
    2. Row 2amount = 120
    3. Row 3amount = NULL

    Expression

    CAST(amount AS VARCHAR)

    Result

    Row 1: '20'
    Row 2: '120'
    Row 3: NULL

    NULL means the value is missing.

    Arguments and types

    CAST(expr AS type)

    The result type can depend on the input types. See DuckDB for the full argument rules.

    Things to know

    Formula output conversion

    For this example, set Output type to DOUBLE.

    'not a number'

    Every row: NULL

    An invalid conversion raises an error

    CAST('unknown' AS DOUBLE)

    This input is rejected: Could not convert string 'unknown' to DOUBLE

    Browse conversion & identifiersDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.