Page 1 of 1

Getting the right range of dates.....

Posted: Fri Nov 15, 2002 5:39 pm
by JPlush76
hey all, I'm trying to get a report that compares this weeks order totals with last weeks order totals...
I have this query for this week:

Code: Select all

<?php
SELECT sum(orders_total) as total, count(orders_id) as ordnum FROM orders WHERE TO_DAYS(NOW()) - TO_DAYS(orders_date) <= 7
?>
that gives me all orders from now to seven days ago.. .what I need is from 8 days ago to 14 days ago.

I'm not sure after read the docs how to subtract time and compare the dates. Anyone? thanks

Posted: Fri Nov 15, 2002 5:54 pm
by JPlush76
bleh, got it

Code: Select all

<?php
SELECT * FROM orders WHERE orders_date < NOW() - INTERVAL 7 DAY AND orders_date > NOW() - INTERVAL 14 DAY
?>