MAKEDATE(year, month, day) returns a date: MAKEDATE(2025, 1, 31) is 31 January 2025. Out-of-range values are adjusted into a date, so 29 February 2025 becomes 1 March 2025 and day 0 is the last day of the previous month. DuckDB's make_date rejects those values, so the matching SQL adds months and days to 1 January.
Updated · Checked on the xmetric engine
What is the syntax?
MAKEDATE(year, month, day)
year, month, day
integers.
Returns a date. Out-of-range months and days roll over into the next or previous month. Null if any part 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.
What date do the year, month and day columns make?
Tableau
MAKEDATE([Y], [M], [D])
SQL (DuckDB)
SELECTCAST (make_date(Y, 1, 1) +to_months(M -1) +to_days(D -1) AS DATE) AS result
FROM input
ORDERBY id
Row 7 is 29 February 2025, which doesn't exist; Tableau rolls it into 1 March. Starting from 1 January and adding months, then days, rolls over the same way.
Y
M
D
Result
2,021
1
1
2021-01-01
2,021
1
3
2021-01-03
2,024
2
29
2024-02-29
2,024
12
29
2024-12-29
2,024
12
30
2024-12-30
2,025
1
31
2025-01-31
2,025
2
29
2025-03-01
2,025
3
2
2025-03-02
null
✓ The Tableau formula and the SQL return the same 9 rows.
What is the last day of each row's month?
Tableau
MAKEDATE([Y], [M]+1, 0)
SQL (DuckDB)
SELECTlast_day(make_date(Y, M, 1)) AS result
FROM input
ORDERBY id
Day 0 of next month is the last day of this one, a common Tableau idiom. In DuckDB, last_day() says it directly: 29 February in 2024, 28 February in 2025.
Y
M
Result
2,021
1
2021-01-31
2,021
1
2021-01-31
2,024
2
2024-02-29
2,024
12
2024-12-31
2,024
12
2024-12-31
2,025
1
2025-01-31
2,025
2
2025-02-28
2,025
3
2025-03-31
null
✓ The Tableau formula and the SQL return the same 9 rows.
Where does a straight translation go wrong?
Common mistake
Why does make_date lose the invalid row?
DuckDB's make_date(2025, 2, 29) is an error, so the bare call fails the query and try() turns the row into null. Tableau adjusts it to 1 March 2025.
Tableau
MAKEDATE([Y], [M], [D])
Tempting SQL
SELECTtry(make_date(Y, M, D)) AS result
FROM input
ORDERBY id
SQL that matches
SELECTCAST (make_date(Y, 1, 1) +to_months(M -1) +to_days(D -1) AS DATE) AS result
FROM input
ORDERBY id
Y
M
D
Tableau
Tempting SQL
SQL that matches
2,021
1
1
2021-01-01
2021-01-01
2021-01-01
2,021
1
3
2021-01-03
2021-01-03
2021-01-03
2,024
2
29
2024-02-29
2024-02-29
2024-02-29
2,024
12
29
2024-12-29
2024-12-29
2024-12-29
2,024
12
30
2024-12-30
2024-12-30
2024-12-30
2,025
1
31
2025-01-31
2025-01-31
2025-01-31
2,025
2
29
2025-03-01
null
2025-03-01
2,025
3
2
2025-03-02
2025-03-02
2025-03-02
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
SELECTDATE_FROM_PARTS(Y, M, D) AS result
FROM input
ORDERBY id