Documentation

    get_bit

    Extracts the nth bit from bitstring; the first (leftmost) bit is indexed 0.

    Try an expression

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

    Expression

    get_bit('0110010'::BITSTRING, 2)

    Result

    1

    To use your own data, replace the example values with column names. Keep format strings and other options as written.

    Arguments and types

    get_bit(bitstring, index)
    bitstring
    Bits
    index
    Number
    Supported signatures (1)
    get_bit(bitstring: BIT, index: INTEGER) → INTEGER

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

    Things to know

    If the first argument is missing, the result is NULL.

    Browse bitsDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.