0

这已经被问了很多,但我发现的答案似乎不起作用,所以我在这里发帖看看是否有人可以提供帮助。

我有这个

$sql = "SELECT SQL_CALC_FOUND_ROWS *, UNIX_TIMESTAMP(order_date) AS order_date, UNIX_TIMESTAMP(order_expected) AS order_expected
            FROM orders WHERE DATE(order_expected) BETWEEN NOW() AND DATE_ADD(NOW() - INTERVAL 7 DAY);

或者

$sql = "SELECT SQL_CALC_FOUND_ROWS *, UNIX_TIMESTAMP(order_date) AS order_date, UNIX_TIMESTAMP(order_expected) AS order_expected
                FROM orders WHERE DATE(order_expected) BETWEEN NOW() AND DATE_ADD(NOW(), INTERVAL -7 DAY);

所有字段的名称都是正确的,但似乎都无法在今天之前的 7 天内获得日期的值。

请帮忙。

伊恩

4

1 回答 1

4

尝试这个:-

SELECT SQL_CALC_FOUND_ROWS *, UNIX_TIMESTAMP(order_date) AS order_date, UNIX_TIMESTAMP(order_expected) AS order_expected
FROM orders 
WHERE DATE(order_expected) BETWEEN DATE_ADD(NOW(), INTERVAL -7 DAY) AND NOW()
于 2014-03-07T12:51:13.340 回答