If you’re getting an error that includes the text “Unrecognized format for strftime/strptime: %” in DuckDB, it appears that you’re including an unescaped percent sign (%
) in your format string when using a function like strftime()
or strptime()
.
Whenever we need a percent sign to be included in the formatted output, we must escape it with another percent sign in the format string.
So to fix this issue, try escaping the percent sign with another percent sign.
Example of Error
Here’s an example of code that produces the error:
SELECT strftime(DATE '2026-12-11', '100% sure that today is %A');
Output:
Invalid Input Error: Failed to parse format specifier 100% sure that today is %A: Unrecognized format for strftime/strptime: %
LINE 1: SELECT strftime(DATE '2026-12-11', '100% sure that today is %A');
The error occurred because I included a percent sign in the format string without escaping it.
Solution
To include a percent sign in the format string, be sure to escape it with another percent sign:
SELECT strftime(DATE '2026-12-11', '100%% sure that today is %A');
Result:
+---------------------------------------------------------------------+
| strftime(CAST('2026-12-11' AS DATE), '100%% sure that today is %A') |
+---------------------------------------------------------------------+
| 100% sure that today is Friday |
+---------------------------------------------------------------------+
This time it worked without error.
Here’s a full list of format specifiers if you’re interested.