select * from table
where date >= date(now())
and date < DATE_ADD(date(now()),INTERVAL 1 DAY)
//最近三个月
date >= DATE_SUB(#{date}, INTERVAL 3 Month) and trade_date <= now()
//当天
select * from 表名 where to_days(时间字段名) = to_days(now());
本文探讨了如何使用SQL进行最近三个月的数据筛选(>3个月前至当前)以及当天操作(当日日期)。重点在于时间戳的比较和日期函数应用。
select * from table
where date >= date(now())
and date < DATE_ADD(date(now()),INTERVAL 1 DAY)
//最近三个月
date >= DATE_SUB(#{date}, INTERVAL 3 Month) and trade_date <= now()
//当天
select * from 表名 where to_days(时间字段名) = to_days(now());
1万+
1314

被折叠的 条评论
为什么被折叠?