Documentation

    hour

    Get the hour, from 0 to 23, from a date or timestamp.

    Try an expression

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

    Expression

    hour(timestamp '2021-08-03 11:59:44.123456')

    Result

    11

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

    Arguments and types

    hour(ts)
    ts
    Date, Interval, Time, Timestamp
    Supported signatures (7)
    hour(ts: DATE) → BIGINT
    hour(ts: INTERVAL) → BIGINT
    hour(ts: TIME WITH TIME ZONE) → BIGINT
    hour(ts: TIME) → BIGINT
    hour(ts: TIMESTAMP WITH TIME ZONE) → BIGINT
    hour(ts: TIMESTAMP) → BIGINT
    hour(ts: TIME_NS) → BIGINT

    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 dates & timesDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.