Open wuwenyishi opened 5 months ago
1、查询今天
SELECT * FROM your_table WHERE DATE(date_column) = CURDATE();
2、查询本周
SELECT * FROM your_table WHERE YEARWEEK(date_column) = YEARWEEK(CURDATE());
3、查询本月
SELECT * FROM your_table WHERE MONTH(date_column) = MONTH(CURDATE()) AND YEAR(date_column) = YEAR(CURDATE());
4、查询近三个月
SELECT * FROM your_table WHERE QUARTER(date_column) = QUARTER(CURDATE());
5、查询近半年
SELECT * FROM your_table WHERE TIMESTAMPDIFF(MONTH, date_column, CURDATE()) <= 6;
6、查询近一年
SELECT * FROM your_table WHERE TIMESTAMPDIFF(YEAR, date_column, CURDATE()) <= 1;
7、查询近三年
SELECT * FROM your_table WHERE TIMESTAMPDIFF(YEAR, date_column, CURDATE()) <= 3;
https://blog.xuemingde.com/posts/11HK0FV.html#more
沉默,有时候是一种无声的反抗