我有一张包含两列的表格,如图所示
在页面执行时,用户输入开始和结束日期。
现在我需要计算的是总额。
例如,如果用户输入
start date: 18-jan-2010
end date: 23-jan-2010
那么他在第一个选项中有 2 个日期(20 美元),在第二个选项中有 3 个日期(26 美元),所以总计为(56 美元)。
首先我想用sql计算
1. how many days in first range (if any this depends on supplied dates from user)
2. how many days in 2nd range (if any this depends on supplied dates from user)
3. how many days in 3rd range (if any this depends on supplied dates from user)
然后
我们将每个范围的天数乘以 php 中的金额。
最后我想在 php 中得到总计。
最佳答案
也许:
从 your_table 中选择 SUM(金额),其中日期位于 start_date 和 end_date 之间,按用户分组
关于php - 计算日期差异金额,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3546728/