假设数据表table中有个字段modifytime的类型为datetime类型或者TIMESTAMP类型
查询当天的数据
select * from table where to_days(modifytime) = to_days(now());
查询前n天的数据
select * from table where to_days(now()) – to_days(modifytime) <= n;
假设数据表汇总有个字段modifytime的类型为int(5)类型,则:
查询当天的数据
select * from table where date_format(from_UNIXTIME(modifytime),'%Y-%m-%d') = date_format(now(),'%Y-%m-%d');
select * from table where to_days(date_format(from_UNIXTIME(modifytime),'%Y-%m-%d')) = to_days(now());