For a description of the range of values owned by each type and the valid format for the specified date and time value, see 7.3.6 Date and Time type.
Here is an example of using a date function. The following query selects all records and its date_col value is within the last 30 days:
mysql> SELECT something FROM table
WHERE TO_DAYS(NOW()) - TO_DAYS(date_col) <= 30;
DayOfWeek (date)
Returns the week index of date (1= Sunday, 2 = Monday, ...). 7= Saturday). These index values correspond to ODBC standards.
mysql> select DAYOFWEEK(@#1998-02-03@#);
-> 3
Weekday (date)
Returns the week index of date (0= Monday, 1 = Tuesday, ...). 6= Sunday).
mysql> select WEEKDAY(@#1997-10-04 22:23:00@#);
-> 5
mysql> select WEEKDAY(@#1997-11-05@#);
-> 2
DayOfMonth (date)
Returns the date in the month of date, in the range 1 through 31.
mysql> select DAYOFMONTH(@#1998-02-03@#);
-> 3
DayOfYear (date)
Returns the number of days in a year, in the range of 1 to 366.
mysql> select DAYOFYEAR(@#1998-02-03@#);
-> 34
MONTH (date)
Returns the month of date, ranging from 1 to 12.
mysql> select MONTH(@#1998-02-03@#);
-> 2
Dayname (date)
Returns the name of the week of date.
mysql> select DAYNAME("1998-02-05");
-> @#Thursday@#
MonthName (date)
Returns the month name of the date.
mysql> select MONTHNAME("1998-02-05");
-> @#February@#
Quarter (date)
Returns the quarter of date one year, ranging from 1 to 4.
mysql> select QUARTER(@#98-04-01@#);
-> 2
WEEK (date)
WEEK (Date,first)
For Sunday is the first day of the week, there is a single parameter that returns the week number of date, ranging from 0 to 52. 2 Parameter Form week () allow
Do you specify whether the week starts in Sunday or Monday. If the second argument is 0, the week begins in Sunday, and if the second argument is 1,