这已经被问了很多,但我找到的答案似乎没有用,所以我发帖在这里看看是否有人可以提供帮助。
我有这个
$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天内获得其日期值。
请帮忙。
伊恩
答案 0 :(得分: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()