DuckDB offers a pretty good range of functions that enable us to get date parts from date or timestamp value. For example, we can extract the month part from a given date value. In most cases, this will be the month number, for example 08 or just 8.
But sometimes we might want to get the actual month name, like October for example. And other times we might just want the abbreviated month name, like Oct.
Fortunately, DuckDB’s got our back. Here are two ways to return the month name from a date or timestamp value in DuckDB.
The monthname() Function
Yes, DuckDB actually has a monthname() function. And yes, it does exactly what it sounds like it might do. It returns the month name from a given date or timestamp value:
SELECT monthname(DATE '2025-08-05') AS monthname;
Result:
+-----------+
| monthname |
+-----------+
| August |
+-----------+
There’s not much else to say about this function. This is pretty much as simple as it gets.
The strftime() Function
The strftime() function has a more general purpose, in that it’s typically used for formatting date and timestamps. But there’s nothing to stop us from using it to return just a single date part, including the month name.
Not only can we get the month name, but we can also get the abbreviated month name if we so wish:
SELECT
strftime(DATE '2025-08-05', '%B') AS full_monthname,
strftime(DATE '2025-08-05', '%b') AS short_monthname;
Result:
+----------------+-----------------+
| full_monthname | short_monthname |
+----------------+-----------------+
| August | Aug |
+----------------+-----------------+
So to get the full month name we use %B (uppercase B), and to get the short month name it’s %b (lowercase b). These are format specifiers. In this example we only wanted the month name and so we only needed to use one format specifier. We can also use multiple format specifiers in order to get multiple date parts in the output. Here’s a full list of format specifiers that can be used with the strftime() function.