Get the Abbreviated Month Name in DuckDB

When working with dates in DuckDB, sometimes we need to extract date parts from date or timestamp values. And when it comes to date parts like days and months, we have the option of getting the numeric representation or the actual name. And if we want the name, we have a further option of getting the full name or the shortened version.

For example, we can get December or we can get Dec.

In DuckDB, we can use the strftime() function to achieve both of these outcomes. This article provides a quick example of using strftime() to get the shortened/abbreviated month name from a date or timestamp value in DuckDB.

Example

Here’s how to use strftime() to get the abbreviated month name from a date value in DuckDB:

SELECT strftime(DATE '2025-12-05', '%b') AS abbreviated_monthname;

Result:

+-----------------------+
| abbreviated_monthname |
+-----------------------+
| Dec |
+-----------------------+

When we use the strftime() function, we pass the date as the first argument and the format string as the second argument. The format string can consist of one or more format specifiers. In our case, our format string only consisted of one format specifier, because we only wanted one date part to be returned (i.e. the abbreviated month name). To achieve this, we used the %b format specifier, because that’s the format specifier that returns the abbreviated month name.

Here are more shortened month names:

.mode line
SELECT 
    strftime(DATE '2025-01-05', '%b') AS January,
    strftime(DATE '2025-02-05', '%b') AS February,
    strftime(DATE '2025-03-05', '%b') AS March,
    strftime(DATE '2025-04-05', '%b') AS April,
    strftime(DATE '2025-05-05', '%b') AS May,
    strftime(DATE '2025-06-05', '%b') AS June,
    strftime(DATE '2025-07-05', '%b') AS July,
    strftime(DATE '2025-08-05', '%b') AS August,
    strftime(DATE '2025-09-05', '%b') AS September,
    strftime(DATE '2025-10-05', '%b') AS October,
    strftime(DATE '2025-11-05', '%b') AS November,
    strftime(DATE '2025-12-05', '%b') AS December;

Result:

  January = Jan
February = Feb
March = Mar
April = Apr
May = May
June = Jun
July = Jul
August = Aug
September = Sep
October = Oct
November = Nov
December = Dec

Here, I used .mode line to format the results using vertical output.

We can switch the format specifier to uppercase if we wanted to get the full month name:

.mode table
SELECT strftime(DATE '2025-12-05', '%B') AS long_monthname;

Result:

+----------------+
| long_monthname |
+----------------+
| December |
+----------------+

We can also use other format specifiers to get other date parts. Here’s a full list of format specifiers that can be used with the strftime() function.