ISOYEAR(date) returns the year that the date's ISO week belongs to. It differs from the calendar year only in the first or last days of a year: 1 January 2021 is ISO year 2020, and 30 December 2024 is ISO year 2025. In DuckDB use isoyear().
Updated · Checked on the xmetric engine
What is the syntax?
ISOYEAR(date)
date
a date or date-time.
Returns an integer: the ISO 8601 week-based year. Null if the date is null.
What does it return, and what is the SQL?
Each example runs on the same 9 sample rows twice: the Tableau formula on the xmetric engine, and the SQL in DuckDB.
Which ISO year does each order belong to?
Tableau
ISOYEAR([Ordered])
SQL (DuckDB)
SELECTisoyear(Ordered) AS result
FROM input
ORDERBY id
Orders 1 and 2 return 2020; order 5 on 30 December 2024 returns 2025.
Ordered
Result
2021-01-0108:00
2,020
2021-01-0318:45
2,020
2024-02-2910:15
2,024
2024-12-2916:25:40
2,024
2024-12-3009:05
2,025
2025-01-3123:59:59
2,025
2025-03-0100:00
2,025
2025-03-0212:30:15
2,025
null
✓ The Tableau formula and the SQL return the same 9 rows.
Which orders have an ISO year different from their calendar year?
Tableau
ISOYEAR([Ordered]) <>YEAR([Ordered])
SQL (DuckDB)
SELECTisoyear(Ordered) <>year(Ordered) AS result
FROM input
ORDERBY id
True for orders 1, 2 and 5: the first days of 2021 and the last Monday of 2024.
Ordered
Result
2021-01-0108:00
true
2021-01-0318:45
true
2024-02-2910:15
false
2024-12-2916:25:40
false
2024-12-3009:05
true
2025-01-3123:59:59
false
2025-03-0100:00
false
2025-03-0212:30:15
false
null
✓ The Tableau formula and the SQL return the same 9 rows.
Where does a straight translation go wrong?
Common mistake
Why does year() disagree with ISOYEAR around New Year?
year() is the calendar year. Orders 1 and 2 (1 and 3 January 2021) are in ISO week 53 of 2020, and order 5 (30 December 2024) is in ISO week 1 of 2025.
Tableau
ISOYEAR([Ordered])
Tempting SQL
SELECTyear(Ordered) AS result
FROM input
ORDERBY id
SQL that matches
SELECTisoyear(Ordered) AS result
FROM input
ORDERBY id
Ordered
Tableau
Tempting SQL
SQL that matches
2021-01-0108:00
2,020
2,021
2,020
2021-01-0318:45
2,020
2,021
2,020
2024-02-2910:15
2,024
2,024
2,024
2024-12-2916:25:40
2,024
2,024
2,024
2024-12-3009:05
2,025
2,024
2,025
2025-01-3123:59:59
2,025
2,025
2,025
2025-03-0100:00
2,025
2,025
2,025
2025-03-0212:30:15
2,025
2,025
2,025
null
null
null
✓ The SQL that matches returns the Tableau result on every row; the marked cells are where the tempting SQL differs.
How do I write it in Snowflake or BigQuery?
The first example, written for each warehouse from its documentation. These are not run here; DuckDB is.
Snowflake
SELECTYEAROFWEEKISO(Ordered) AS result
FROM input
ORDERBY id
Whenever you group or label by ISO week. A week number only makes sense next to its ISO year; with the calendar year, the weeks around New Year get the wrong year.
Which days change year?
Up to three days at each end of a calendar year. ISO year 2025 starts on Monday 30 December 2024; ISO year 2020 runs until Sunday 3 January 2021.