Tableau function Date

Tableau ISOWEEKDAY to SQL

ISOWEEKDAY(date) returns the ISO 8601 day of the week: Monday is 1 and Sunday is 7, whatever the data source's week start. DuckDB's isodow() is the same. dayofweek() is not: it counts from Sunday = 0.

Updated · Checked on the xmetric engine

What is the syntax?

ISOWEEKDAY(date)
date
a date or date-time.

Returns an integer from 1 (Monday) to 7 (Sunday). 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 weekday was each order placed on?

Tableau

ISOWEEKDAY([Ordered])

SQL (DuckDB)

SELECT isodow(Ordered) AS result
FROM input
ORDER BY id

Order 5 is a Monday (1); orders 2, 4 and 8 are Sundays (7).

OrderedResult
2021-01-01 08:005
2021-01-03 18:457
2024-02-29 10:154
2024-12-29 16:25:407
2024-12-30 09:051
2025-01-31 23:59:595
2025-03-01 00:006
2025-03-02 12:30:157
null

The Tableau formula and the SQL return the same 9 rows.

Was the order placed at the weekend?

Tableau

ISOWEEKDAY([Ordered]) >= 6

SQL (DuckDB)

SELECT isodow(Ordered) >= 6 AS result
FROM input
ORDER BY id

With Monday = 1, Saturday and Sunday are the two highest numbers.

OrderedResult
2021-01-01 08:00false
2021-01-03 18:45true
2024-02-29 10:15false
2024-12-29 16:25:40true
2024-12-30 09:05false
2025-01-31 23:59:59false
2025-03-01 00:00true
2025-03-02 12:30:15true
null

The Tableau formula and the SQL return the same 9 rows.

Where does a straight translation go wrong?

Common mistake

Why does dayofweek() give 0 for Sunday?

DuckDB's dayofweek() counts from Sunday = 0 to Saturday = 6. ISOWEEKDAY counts Monday = 1 to Sunday = 7, so every Sunday is 0 instead of 7 and every other day matches only by accident.

Tableau

ISOWEEKDAY([Ordered])

Tempting SQL

SELECT dayofweek(Ordered) AS result
FROM input
ORDER BY id

SQL that matches

SELECT isodow(Ordered) AS result
FROM input
ORDER BY id
OrderedTableauTempting SQLSQL that matches
2021-01-01 08:00555
2021-01-03 18:45707
2024-02-29 10:15444
2024-12-29 16:25:40707
2024-12-30 09:05111
2025-01-31 23:59:59555
2025-03-01 00:00666
2025-03-02 12:30:15707
nullnullnull

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

SELECT DAYOFWEEKISO(Ordered) AS result
FROM input
ORDER BY id

Snowflake documentation

BigQuery

SELECT MOD(EXTRACT(DAYOFWEEK FROM Ordered) + 5, 7) + 1 AS result
FROM input
ORDER BY id

BigQuery documentation

What does your own ISOWEEKDAY formula return?

Edit the formula and run it on the 9 sample rows. Fields: [id], [Ordered], [Due], [Text], [Local], [Y], [M], [D].

Runs in your browser on the xmetric engine. Nothing is uploaded.

Which functions go with it?

What do people ask about ISOWEEKDAY?

How is ISOWEEKDAY different from DATEPART('weekday', ...)?

DATEPART('weekday') follows the data source's week start, so in US English Sunday is 1 and Saturday 7. ISOWEEKDAY always has Monday 1 and Sunday 7.

How do I flag weekend orders?

ISOWEEKDAY([Ordered]) >= 6; in SQL isodow(Ordered) >= 6. Orders 2, 4, 7 and 8 are weekend orders.

What does ISOWEEKDAY return for a null date?

Null, in Tableau and in SQL.

Where is this documented?