The DAYOFWEEK()
function returns the weekday index from a date sent as a parameter.
Figure 1 shows a visual representation of the DAYOFWEEK()
function and the week index.
DAYOFWEEK(date)
The DAYOFWEEK()
function takes the date as a parameter.
The date must be in the format YYYY-MM-DD, or else this function returns
NULL
.
The DAYOFWEEK()
function returns the week index from a date sent as a parameter.
It returns
NULL
if the date is invalid.
-- current dateSELECT DAYOFWEEK(NOW());-- invalid monthSELECT DAYOFWEEK('2021-0-12');-- valid month/daySELECT DAYOFWEEK('2021-05-03');-- invalid daySELECT DAYOFWEEK('2021-2-30');