不确定为什么此查询不会返回并获取当前月份之前的记录。上个月它工作得很好,然后今天是 6 月 1 日,它不会检索上个月的记录。
过去 7 天
SELECT SUM(sum) AS sum FROM cl_work_orders WHERE user_id = ? AND workorder_date <= CURDATE() AND workorder_date > (CURDATE() - 8)
过去 30 天
SELECT SUM(sum) AS sum FROM cl_work_orders WHERE user_id = ? AND workorder_date <= CURDATE() AND workorder_date > (CURDATE() - 31)
昨天
SELECT SUM(sum) AS sum FROM cl_work_orders WHERE user_id = ? AND workorder_date < CURDATE() AND workorder_date > (CURDATE() - 2)
上个月他们都工作得很好。上个月刚刚启动该站点,因此在今天之前无法看到“新月份”问题。