/*近7天*/
select * from 表名 where date_sub(curdate(), interval 7 day) = date(时间字段);
/*查询距离当前现在6个月的数据*/
select * from 表名 where 时间字段 between date_sub(now(),interval 6 month) and now();
/*查询当前这周的数据*/
select * from 表名 where yearweek(date_format(时间字段,'%Y-%m-%d')) = yearweek(now());
/*查询上周的数据*/
select * from 表名 where yearweek(date_format(时间字段,'%Y-%m-%d')) = yearweek(now())-1;
/*查询当前月份的数据*/
select * from 表名 where date_format(时间字段,'%Y-%m')=date_format(now(),'%Y-%m');
/*查询上个月的数据*/
select * from 表名 where date_format(时间字段,'%Y-%m')=date_format(date_sub(curdate(), interval 1 month),'%Y-%m');
其它获取类似以上的代码显示
关于php获取当天的数据和php获取当天的数据的方法是的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息 , 记得收藏关注本站 。
推荐阅读
- 怎么判断显卡的好坏,怎么判断显卡的好坏图解
- 单机免费游戏下载,单机游戏免费版
- 天天格斗破解版手机游戏,天天格斗破解版下载安装
- 视频号小店直播付费要求,视频号小商店要钱吗
- php网站连接不上数据库 php连接数据库失败是什么原因
- 包含jqueryuifilter的词条
- css鼠标移过字体改变效果,css鼠标移入移出切换事件
- 跨境电商如何推广爆款,跨境电商如何营销推广
- C语言函数数组逆序 c程序数组逆序