Available in versions: Dev (3.20) | Latest (3.19) | 3.18 | 3.17 | 3.16 | 3.15 | 3.14 | 3.13 | 3.12

ISO_DAY_OF_WEEK

Applies to ✅ Open Source Edition   ✅ Express Edition   ✅ Professional Edition   ✅ Enterprise Edition

Extract the ISO_DAY_OF_WEEK value from a datetime value.

The ISO_DAY_OF_WEEK function is a short version of the EXTRACT, passing a DatePart.ISO_DAY_OF_WEEK value as an argument.

SELECT iso_day_of_week(DATE '2020-02-03');
create.select(isoDayOfWeek(Date.valueOf("2020-02-03"))).fetch();

The result being (Monday = 1, ..., Sunday = 7)

+-----------------+
| iso_day_of_week |
+-----------------+
|               7 |
+-----------------+

Dialect support

This example using jOOQ:

isoDayOfWeek(Date.valueOf("2020-02-03"))

Translates to the following dialect specific expressions:

ASE

(((DATEPART(dw, '2020-02-03 00:00:00.0') + @@datefirst + 5) % 7) + 1)

Aurora MySQL, MariaDB, MySQL

weekday(TIMESTAMP '2020-02-03 00:00:00.0') + 1

Aurora Postgres, CockroachDB, Postgres

extract(ISODOW FROM TIMESTAMP '2020-02-03 00:00:00.0')

DB2

DAYOFWEEK_ISO(TIMESTAMP '2020-02-03 00:00:00.0')

H2

extract(ISO_DAY_OF_WEEK FROM TIMESTAMP '2020-02-03 00:00:00.0')

Hana

(weekday(TIMESTAMP '2020-02-03 00:00:00.0') + 1)

HSQLDB

(mod(
  (EXTRACT(DAY_OF_WEEK FROM TIMESTAMP '2020-02-03 00:00:00.0') + 5),
  7
) + 1)

MemSQL

weekday({ts '2020-02-03 00:00:00.0'}) + 1

Oracle

to_number(to_char(TIMESTAMP '2020-02-03 00:00:00.0', 'D'))

SQLDataWarehouse, SQLServer

(((DATEPART(dw, CAST('2020-02-03 00:00:00.0' AS DATETIME2)) + @@datefirst + 5) % 7) + 1)

SQLite

(((CAST(strftime('%w', '2020-02-03 00:00:00.0') AS int) + 6) % 7) + 1)

Sybase

(mod(
  (DATEPART(dw, '2020-02-03 00:00:00.0') + @@datefirst + 5),
  7
) + 1)

Access, BigQuery, ClickHouse, Derby, DuckDB, Exasol, Firebird, Informix, Redshift, Snowflake, Teradata, Trino, Vertica, YugabyteDB

/* UNSUPPORTED */
Generated with jOOQ 3.20. Translate your own SQL on our website

Feedback

Do you have any feedback about this page? We'd love to hear it!

The jOOQ Logo