yearweek专题

mysql YEARWEEK(date[,mode]) 函数 查询上周数据

通常使用下边sql即可(如果数据库设置了周一为一周起始的话): -- 查询上周数据(addtime为datetime格式)SELECT id,addtime FROM mall_order WHERE YEARWEEK(date_format(addtime,'%Y-%m-%d')) = YEARWEEK(now())-1; YEARWEEK(date[,mode]) 函数默认西方