0

This has been asked quite alot but the answer i found dont seem to work, so im posting here to see if someone can help.

I have this

$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);

or

$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);

all fields are name correct but neither seem to be able to get a value with its date within 7 days before today.

Please help.

Ian

snookian
  • 863
  • 6
  • 13
  • 35

1 Answers1

4

Try this:-

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()
Kickstart
  • 21,403
  • 2
  • 21
  • 33