Reference links: https://blog.csdn.net/snihcel/article/details/80088195 (Reference)
https://www.runoob.com/mysql/mysql-functions.html (a function MySql)
https://blog.csdn.net/dxhtostage/article/details/82792789 (Mysql in the count () using the syntax)
https://www.cnblogs.com/yueguanguanyun/p/7911448.html (report query)
First, the annual query (query data year)
SELECT * FROM tableName
WHERE year(tableName.timer) = year(curdate( ));
Where: 1.year (...) returns the year
SELECT YEAR("2017-06-15"); -> 2017
2.curdate () returns the current date
SELECT CURDATE(); -> 2018-09-19
3.now () returns the current date and time
SELECT NOW() -> 2019-11-11 20:20:00
Note: tableName is the table name, timer date type of field. year () is used to calculate annual date, curdate () indicates the current time
Second, the inquiry quarterly data
SELECT *
FROM tableName
WHERE quarter(tableName.timer) = quarter(curdate( ));
Wherein: quarter () Returns the date d is the first of several seasons, return 1-4
SELECT QUARTER('2011-11-11 11:11:11') -> 4
Third, the monthly data query
select * from tableName where month(tableName.timer)=
month(curdate());
Wherein: month () Returns the month of the date d, 1-12
SELECT MONTH('2011-11-11 11:11:11') ->11