DAYOFWEEK_ISO

The DAYOFWEEK_ISO function returns an integer between 1 and 7 that represents the day of the week, where 1 is Monday and 7 is Sunday.

Read syntax diagramSkip visual syntax diagramDAYOFWEEK_ISO (expression)

For another alternative, see DAYOFWEEK.

expression
An expression that returns a value of one of the following built-in data types: a date, a timestamp, a character string, or a graphic string.

If expression is a character or graphic string, its value must be a valid string representation of a date or timestamp. For the valid formats of string representations of dates and timestamps, see String representations of datetime values.

The result of the function is a large integer. If the argument can be null, the result can be null; if the argument is null, the result is the null value.

Examples

  • Using the EMPLOYEE table, set the host variable DAY_OF_WEEK (INTEGER) to the day of the week that Christine Haas (EMPNO=‘000010') started (HIREDATE).
      SELECT DAYOFWEEK_ISO(HIREDATE)
        INTO :DAY_OF_WEEK
        FROM EMPLOYEE     
        WHERE EMPNO = '000010'
    Results in DAY_OF_WEEK being set to 5, which represents Friday.
  • The following query returns four values: 7, 1, 7, and 1.
      SELECT DAYOFWEEK_ISO(CAST('10/11/1998' AS DATE)),
             DAYOFWEEK_ISO(TIMESTAMP('10/12/1998','01.02')),
             DAYOFWEEK_ISO(CAST(CAST('10/11/1998' AS DATE) AS CHAR(20))),
             DAYOFWEEK_ISO(CAST(TIMESTAMP('10/12/1998','01.02') AS CHAR(26)))
        FROM SYSIBM.SYSDUMMY1