过滤指定日期
1.近1天1
2
3select * from table where to_days(column_time) = to_days(now());
select * from table where date(column_time) = curdate();
2.近7天1
select * from table where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(column_time);
3.近一个月1
select * from table where DATE_SUB(CURDATE(), INTERVAL 1 MONTH) <= date(column_time);
筛选出需要的日期的值
1.筛选出年月日1
select DATA(column_time) from table ;
2.筛选出年月1
select Extract(year_month FROM column_time) from table ;
3.筛选出年.1
select Extract(year FROM column_time) from table ;
4.筛选出月1
select Extract(month FROM column_time) from table ;
5.筛选出日1
select Extract(day FROM column_time) from table ;
6.筛选出时分秒1
select time(day FROM column_time) from table ;
比较日期
1.间隔天数1
SELECT match_date,create_time FROM table_name WHERE datediff(match_date,create_time) = 60
详见: 官方文档