What is DAYOFMONTH() in SQL?
The DAYOFMONTH() function returns what day of the month it is from a date sent as a parameter.
Figure 1 shows a visual representation of the DAYOFMONTH() function.
Syntax
DAYOFMONTH(date)
Parameter
The DAYOFMONTH() function takes the date as a parameter.
The date must be in the format YYYY-MM-DD, or else this function returns
NULL.
Return value
The DAYOFMONTH() function returns the day of the month from a date sent as a parameter.
It returns
NULLif the date is invalid.
Code
-- current dateSELECT DAYOFMONTH(NOW());-- invalid monthSELECT DAYOFMONTH('2021-13-12');-- valid month/daySELECT DAYOFMONTH('2021-05-03');-- invalid daySELECT DAYOFMONTH('2021-2-30');