DAYOFWEEK scalar function

The DAYOFWEEK function returns the day of the week in the first argument as an integer value. The integer value is in the range 1-7, where 1 represents the first day of the week, as specified in the second argument.

Read syntax diagramSkip visual syntax diagramDAYOFWEEK(expression ,start-of-week )

The schema is SYSIBM. The SYSFUN version of the DAYOFWEEK function continues to be available.

expression
An expression that specifies the datetime value from which the day of the week is determined. The expression must return a value that is a DATE, TIMESTAMP, CHAR, or VARCHAR data type. In a Unicode database, the expression can also be a GRAPHIC or VARGRAPHIC data type. If expression is a CHAR, VARCHAR, GRAPHIC, or VARGRAPHIC data type, it must be a valid string representation of a date or timestamp.
start-of-week
An expression that specifies the starting day of the week. The expression must return a value that is a built-in numeric, CHAR, or VARCHAR data type. In a Unicode database, the expression can also be a GRAPHIC or VARGRAPHIC data type. CHAR, VARCHAR, GRAPHIC, and VARGRAPHIC are supported by using implicit casting. The value must be in the range 1 - 7 (SQLSTATE 42815), where 1 represents Sunday. If not specified, the default value is 1.

The result of the function is INTEGER. If any argument can be null, the result can be null; if any argument is null, the result is the null value.