New versions: Dev (3.15) | Latest (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, MEMSQL, MYSQL
weekday({ts '2020-02-03 00:00:00.0'}) + 1

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

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

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

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

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

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

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

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

-- ACCESS, COCKROACHDB, DB2, DERBY, FIREBIRD, HANA, INFORMIX, INGRES, REDSHIFT, SQLDATAWAREHOUSE, TERADATA, VERTICA
/* UNSUPPORTED */

(These are currently generated with jOOQ 3.15, see #10141)

Feedback

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

The jOOQ Logo