Mega Code Archive

 
Categories / MySQL Tutorial / Date Time Functions
 

Getting Day Information

There are four functions for converting a date to a day number: DAYOFYEAR(date) DAYOFMONTH(date) DAYOFWEEK(date) WEEKDAY(date) DAYOFYEAR(date) returns the day of the year for a given date (in numeric format). DAYOFYEAR(date) returns how many days since January 1 of that year. mysql> mysql> SELECT DAYOFYEAR(20000201); +---------------------+ | DAYOFYEAR(20000201) | +---------------------+ |                  32 | +---------------------+ 1 row in set (0.01 sec)