Documentation

    age

    Calculate the time between two timestamps as an interval, subtracting the second from the first.

    Try an expression

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

    Expression

    age(TIMESTAMP '2001-04-10', TIMESTAMP '1992-09-20')

    Result

    '8 years 6 months 20 days'

    The expression returns INTERVAL. Formula stores it as VARCHAR in this example. To use your own data, replace the example values with column names. Keep format strings and other options as written.

    Arguments and types

    age(timestamp, timestamp)
    timestamp
    Timestamp
    Supported signatures (4)
    age(timestamp: TIMESTAMP WITH TIME ZONE) → INTERVAL
    age(timestamp: TIMESTAMP WITH TIME ZONE, timestamp: TIMESTAMP WITH TIME ZONE) → INTERVAL
    age(timestamp: TIMESTAMP) → INTERVAL
    age(timestamp: TIMESTAMP, timestamp: TIMESTAMP) → INTERVAL

    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.