Do your date maths in the database. That's my first hint. If your database doesn't do date math well, then use a different database that does.
Newer versions of MySQL are pretty good, PostgreSQL is excellent.
Find your date truncation functions. In postgresql it's date_trunc, and this lets you truncate a date down to a certain field. I.e. hours, minutes, days, seconds, etc...
2006-01-12 12:13:34 date trunced to day becomes 2006-01-12 00:00:00 and so on.
Use ranges. Where datefield between '2006-01-01 00:00:00' and '2006-01-07 23:59:59'
study and use time zones if needed. Generally you're better off using them from the start so that when you need to operate across time zones you're ready.
And, in your spare time, read that book, eh?