Documentation

    strftime

    Format a date or timestamp as text using a format string such as %d/%m/%Y.

    Try an expression

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

    Expression

    strftime(DATE '2024-03-15', '%Y-%m')

    Result

    '2024-03'

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

    Arguments and types

    strftime(data, format)
    data
    Date, Timestamp, Text
    format
    Date, Timestamp, Text
    Supported signatures (8)
    strftime(data: DATE, format: VARCHAR) → VARCHAR
    strftime(data: TIMESTAMP WITH TIME ZONE, format: VARCHAR) → VARCHAR
    strftime(data: TIMESTAMP, format: VARCHAR) → VARCHAR
    strftime(data: TIMESTAMP_NS, format: VARCHAR) → VARCHAR
    strftime(data: VARCHAR, format: DATE) → VARCHAR
    strftime(data: VARCHAR, format: TIMESTAMP WITH TIME ZONE) → VARCHAR
    strftime(data: VARCHAR, format: TIMESTAMP) → VARCHAR
    strftime(data: VARCHAR, format: TIMESTAMP_NS) → VARCHAR

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

    Things to know

    Format strings control the output. %Y is the four-digit year and %m is the two-digit month.

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

    Browse dates & timesDuckDB documentation

    Function metadata from DuckDB, used under the MIT license.