The DAYOFYEAR()
function returns the day of the year from a date sent as a parameter. There are 365 days in a year.
There are 366 days in a leap year.
Figure 1 shows a visual representation of the DAYOFYEAR()
function.
-- current dateSELECT DAYOFYEAR(NOW());-- invalid monthSELECT DAYOFYEAR('2021-13-12');-- valid month/daySELECT DAYOFYEAR('2021-05-03');-- invalid daySELECT DAYOFYEAR('2021-2-30');