Documentation

    TRY_CAST

    Convert a value to another data type, returning a missing value if conversion fails.

    Try an expression

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

    Example input

    1. Row 1amount = '12.5'
    2. Row 2amount = 'unknown'
    3. Row 3amount = NULL

    Expression

    TRY_CAST(amount AS DOUBLE)

    Result

    Row 1: 12.5
    Row 2: NULL
    Row 3: NULL

    NULL means the value is missing.

    Arguments and types

    TRY_CAST(expr AS type)

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

    Browse conversion & identifiersDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.