code_junkie

PHP/MySQL: Retrieving the last *full* weeks entries

Nov 12th, 2011
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.24 KB | None | 0 0
  1. purchased >= date_sub(now() ,interval 7 day)
  2.  
  3. SELECT * FROM table WHERE YEARWEEK(purchased) = YEARWEEK(NOW());
  4.  
  5. $sunday = date(('Y-m-d H:i:s'), strtotime('last sunday 00:00'));
  6. $sql = "SELECT * FROM table WHERE purchased >= '$sunday'";
Add Comment
Please, Sign In to add comment