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, 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) -- 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')) -- 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, DERBY, DUCKDB, EXASOL, FIREBIRD, INFORMIX, REDSHIFT, SNOWFLAKE, TERADATA, TRINO, VERTICA, YUGABYTEDB /* UNSUPPORTED */
(These are currently generated with jOOQ 3.19, see #10141), or translate your own on our website
Feedback
Do you have any feedback about this page? We'd love to hear it!