This article mainly summarizes some commonly used in the actual use of some of the MySQL time and date and conversion function
1.now (): Returns the current date and time
Select Now (); // 2018-04-21 09:19:21
2.curdate (): Returns the current date
Select curdate (); //
3. DayOfWeek (data): Return date data is the day of the week
(1 = Sunday, 2 = Monday ...) 7= Saturday, ODBC Standard)
Select DayOfWeek ('2018--- 3
4.weekday (date): Return date data is the day of the week
(0 = Sunday, 1 = Monday ...) 6= Saturday, ODBC Standard)
Select WEEKDAY ('1997-10-04 22:23:00'); // 5
5.dayofmonth (date): Return date is the day of the one month (1-31 range)
Select dayofmonth ('2018-04-21'); // +
6.dayofyear (date): Returns date is the day ordinal of the year (1-366 range)
Select dayofyear ('2018-01-01'); // 1
7.Month (date): Returns the month value in date
Select Month ('2018-04-21'); // 4
8.dayname (date): Returns the day of the week (English name returned)
Select dayname ('1998-02-05'); // Thursday
9.monthname (date): Returns a date of several months (return in English)
Select monthname ('2018-02-01')//February
10.quarter (date): Returns the quarter ordinal of a year
Select Quarter ('2018-04-21'); // 2
11.week (Date,first): Returns date is the week ordinal of a year
(The parameter first:0 indicates that Sunday is the beginning of the week, 1 indicates that Monday is the beginning of the week, the default 0)
Select Week ('2018-02-20'// 7Select Week (' 2018-02-20 ',0//7Select Week ('2018-02-20' ,1//8
12.year (date): Returns the year in date (range 1000-9999)
Select Year ('98-02-03'); // 1998
Not finished ...
:
Summary of time and date functions commonly used by MySQL