title: How to set SQL to find records from last sunday to this sunday (1 week)
body: <p>This is similar to what I have now, which is:</p>
  
  <p><code>SELECT COUNT(author) FROM `posts` WHERE `date` &gt;= DATE_SUB(CURDATE(), INTERVAL 1 WEEK) AND author='FooBar'</code></p>
  
  <p>This will give me a count of how many times an author has posted in the past 1 week.</p>
  
  <p>I want to instead have it so if I am to run the program on Sunday at 5:30 PM to look for posts from last Sunday 12:00 AM to this Sunday 12:00 AM. Likewise, if I forget to run it on Sunday and it's monday now. I still want it to run from last Sunday 12:00 AM to the Sunday that just past 12:00 AM </p>
  
  <p>Edit:</p>
  
  <p>I have done what I needed using PHP to form the correct SQL statement, but I am still curious how to do this in just SQL.</p>
  
  <pre><code>&lt;?php
      $dayofweek = strftime("%A",time());
      if($dayofweek == "Sunday") {
          $last_sunday = date('Y-m-d h:i:s',strtotime('Last Sunday'));
          $this_sunday = date('Y-m-d h:i:s',strtotime('Sunday'));
      } else {
          $last_sunday = date('Y-m-d h:i:s',strtotime('Last Sunday',strtotime('Last Sunday')));
          $this_sunday = date('Y-m-d h:i:s',strtotime('Last Sunday'));
      }
      print "last_sunday={$last_sunday}&lt;br&gt;";
      print "this_sunday={$this_sunday}&lt;br&gt;";
      print "SELECT COUNT(author) FROM `posts` WHERE `date` &lt;= '$this_sunday' AND `date` &gt;= '$last_sunday' AND author='FooBar'";
  ?&gt;
  </code></pre>