Documentation

    date_sub

    Count the complete units between two dates or timestamps. For example, January 31 to February 1 is zero complete months. Also available as datesub.

    Try an expression

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

    Expression

    date_sub('month', DATE '1992-09-15', DATE '1992-11-14')

    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

    date_sub(part, startdate, enddate)
    part
    Text
    startdate
    Date, Time, Timestamp
    enddate
    Date, Time, Timestamp
    Supported signatures (4)
    date_sub(part: VARCHAR, startdate: DATE, enddate: DATE) → BIGINT
    date_sub(part: VARCHAR, startdate: TIME, enddate: TIME) → BIGINT
    date_sub(part: VARCHAR, startdate: TIMESTAMP WITH TIME ZONE, enddate: TIMESTAMP WITH TIME ZONE) → BIGINT
    date_sub(part: VARCHAR, startdate: TIMESTAMP, enddate: TIMESTAMP) → 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.