PHP MySQL 总日期范围

标签 php mysql

我的数据库结构如下:

id | start           | end             |
---+-----------------+-----------------+
1  |2016/01/01 10:00 |2016/01/10 09:45 |
---+-----------------+-----------------+
2  |2016/01/03 15:30 |2016/01/17 22:35 |
---+-----------------+-----------------+
3  |2016/01/12 17:15 |2016/01/20 11:20 |
...

我想找到这两个日期的天数范围,并对所有天数求和。也许有人有解决方案?

最佳答案

使用从您的表中选择 DATEDIFF(dateField1, dateField2) 作为 dateInDays http://www.w3schools.com/sql/func_datediff_mysql.asp

关于PHP MySQL 总日期范围,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34925887/

相关文章:

mysql - 将 mysql 聚合行重新组织为单片行

php - 从数据库 SQL 中的唯一 ID 获取最后一个数字 - PHP CodeIgniter

php - 统计MySQL中的投票频率

python - 错误: Setup script exited with error: command 'gcc' failed with exit status 1

javascript - 如何从 Javascript 调用 PHP 文件并将数据从 PHP 返回到 Javascript

php - 如何只使用某些验证集来验证 Cake PHP 中的数据?

javascript - 从 PHP 脚本返回 JSON 对象

PHP/MySQL/GWT 合并字符串序列,不重复排列

php - 基本创建表MYSQL语法错误

php - 谷歌图表中未显示确切值