如何利用php语法查询指定时间段内数据库中的数据,下面编程教程网小编给大家简单介绍一下具体代码!
实现代码如下:
$month = '01';
$year = '2023';
$max_day = cal_days_in_month(CAL_GREGORIAN, $month, $year); //当月最后一天
$min = $year.'-'.$month.'-01 00:00:00';
$max = $year.'-'.$month.'-'.$max_day.' 23:59:59';
$sql = "select t.enterdate,count(*) as total_num,sum(t.total_price) as amount (select date_format(enterdate,'%e') as enterdate,total_price from orders where enterdate between {$min} and {$max}) t group by t.enterdate order by t.enterdate";
$return = mysqli_query($sql);
以上是编程学习网小编为您介绍的“php语法如何查询指定时间段内的数据”的全面内容,想了解更多关于 php入门 内容,请继续关注编程基础学习网。
沃梦达教程
本文标题为:php语法如何查询指定时间段内的数据
猜你喜欢
- php7 list()、session及其他模块的修改实例分析 2023-04-19
- Lumen timezone 时区设置方法(慢了8个小时) 2022-10-05
- PHPstorm激活码2020年5月13日亲测有效 2023-05-02
- tp5 实现列表数据根据状态排序 2023-03-03
- PHP利用pdo_odbc实现连接数据库示例【基于ThinkPHP5.1搭建的项目】 2023-01-15
- Cookie跨域问题解决方案代码示例 2023-05-03
- PHP中将字符串转化为整数(int) intval() printf() 性能测试 2024-01-12
- PHP设计模式之适配器模式定义与用法详解 2022-10-12
- PHP容易被忽略而出错陷阱 数字与字符串比较 2024-02-18
- PHP的邮件群发系统phplist配置方法详细总结 2023-12-12