Fix ‘Conversion Error: extract specifier “monthname” not recognized’ in DuckDB

If you’re getting an error that reads “Conversion Error: extract specifier “monthname” not recognized” in DuckDB, it appears that you’re using a function like extract() or date_part() to try to get the month name from a date.

These functions don’t accept a monthname specifier, and so that’s why the error occurs. Fortunately, DuckDB provides a monthname() function, and so you could try that instead. Also, the strftime() function has a format specifier for the month name, and so that’s another option.

So to fix this issue, try the monthname() or strftime() function instead.

Example of Error

Here’s an example of code that produces the error:

SELECT extract('monthname' FROM DATE '2025-08-05');

Output:

Conversion Error: extract specifier "monthname" not recognized

The error is quite self-explanatory; it’s telling us that we can’t use monthname as a specifier with this function.

The same error occurs when we try the date_part() function:

SELECT date_part('monthname', DATE '2025-08-05');

Output:

Conversion Error: extract specifier "monthname" not recognized

So the date_part() function doesn’t accept monthname as a specifier either.

Solution 1

DuckDB provides a monthname() function, and so that’s one option:

SELECT monthname(DATE '2025-08-05');

Result:

+---------------------------------------+
| monthname(CAST('2025-08-05' AS DATE)) |
+---------------------------------------+
| August |
+---------------------------------------+

This time it worked without error.

Solution 2

When using DuckDB’s strftime() function, we can pass the %B format specifier for the full month name, and so that’s another option. We can use a lowercase b if we want the short month name:

SELECT 
    strftime(DATE '2025-10-05', '%B') AS full_monthname,
    strftime(DATE '2025-10-05', '%b') AS short_monthname;

Result:

+----------------+-----------------+
| full_monthname | short_monthname |
+----------------+-----------------+
| October | Oct |
+----------------+-----------------+

The strftime() function is designed to format date and timestamp values, and so there are format specifiers for each date/time part. Here’s a full list of format specifiers that can be used with strftime().