select * from wap_content where week(created_at) = week(now)
创新互联是一家专业提供黄石港企业网站建设,专注与网站设计制作、网站制作、H5高端网站建设、小程序制作等业务。10年已为黄石港众多企业、政府机构等服务。创新互联专业网站制作公司优惠进行中。
如果你要严格要求是某一年的,那可以这样
查询一天:
select * from table where to_days(column_time) = to_days(now());
select * from table where date(column_time) = curdate();
查询一周:
select * from table where DATE_SUB(CURDATE(), INTERVAL 7 DAY) = date(column_time);
查询一个月:
select * from table where DATE_SUB(CURDATE(), INTERVAL INTERVAL 1 MONTH) = date(column_time);
mysql中怎么查询一周内,三个月内\x0d\x0a使用sql语句查询日期在一周内的数据\x0d\x0aselect * from ShopOrder where datediff(week,ordTime,getdate()-1)=0 //查询当天日期在一周年的数据\x0d\x0aselect * from ShopOrder where datediff(day,ordTime,getdate()-1)=0 //查询当天的所有数据\x0d\x0a SELECT * FROM A where datediff(d,datetime,getdate())
回答于 2022-12-11
查询当前这周的数据
SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now());
查询上周的数据
SELECT name,submittime FROM enterprise WHERE YEARWEEK(date_format(submittime,'%Y-%m-%d')) = YEARWEEK(now())-1;
查询当前月份的数据
select name,submittime from enterprise where date_format(submittime,'%Y-%m')=date_format(now(),'%Y-%m')