If you’re getting an error that reads “Not implemented Error: Unknown TimeZone” in DuckDB, it appears that you’re using an unknown timezone when specifying a timezone for a timestamp value.
To fix this issue, be sure to use a supported timezone.
Example of Error
Here’s an example of code that produces the error:
SELECT TIMESTAMP '2035-07-20 12:35:45+08' AT TIME ZONE 'Mars';
Output:
Not implemented Error: Unknown TimeZone 'Mars'
We got an error, because Mars is not a known timezone.
We’ll get the same error if we use a numeric timezone:
SELECT TIMESTAMP '2035-07-20 12:35:45+08' AT TIME ZONE '0500';
Output:
Not implemented Error: Unknown TimeZone '0500'
Although DuckDB does allow numeric timezones in some contexts, it can’t be used in this context.
Solution
To fix this issue, we must make sure that the timezone is valid and known to DuckDB. This can be the actual timezone name or its abbreviation.
For example:
SELECT TIMESTAMP '2035-07-20 12:35:45+08' AT TIME ZONE 'Africa/Abidjan';
Result:
+------------------------------------------------------------------------------+
| main.timezone('Africa/Abidjan', CAST('2035-07-20 12:35:45+08' AS TIMESTAMP)) |
+------------------------------------------------------------------------------+
| 2035-07-20 14:35:45+10 |
+------------------------------------------------------------------------------+
This time it ran without error.
Get a List of Timezones
We can use the pg_timezone_names()
table function to get a list of available timezones:
SELECT
name,
abbrev
FROM
pg_timezone_names()
ORDER BY name;
Result:
+--------------------+----------------+
| name | abbrev |
+--------------------+----------------+
| ACT | ACT |
| AET | AET |
| AGT | AGT |
| ART | ART |
| AST | AST |
| Africa/Abidjan | Iceland |
| Africa/Accra | Iceland |
| Africa/Addis_Ababa | EAT |
| Africa/Algiers | Africa/Algiers |
| Africa/Asmara | EAT |
...
It’s quite a long list, and so I’ve only presented the first ten rows here.