title: MySQL: week date range from week number in a query
body: <p>I got a database table that looks something like this:</p>
  
  <pre><code>| id         | clock         | info
  ----------------------------------------------
  | 1          | 1262556754    | some info
  | 2          | 1262556230    | some other info
  | 3          | 1262556988    | and another
  | 4          | 1262555678    | and some more
  </code></pre>
  
  <p>It contains log records and a unix timestamp, when this log was written. What I need, is to get a weekly report, on how many log records there was during each week. Here is a query that I wrote:</p>
  
  <pre><code>SELECT
      DATE_FORMAT(FROM_UNIXTIME(clock), "%U") AS week
  count(*) as cnt
  FROM logs
  WHERE DATE_FORMAT(FROM_UNIXTIME(clock), "%Y") = '2010'
  GROUP BY week
  </code></pre>
  
  <p>This gives a result like this:</p>
  
  <pre><code>| week       | cnt
  -------------------------------
  | 1           | 55 
  | 2           | 134   
  | 4           | 765
  | 20          | 65
  </code></pre>
  
  <p>Great! But what I would like to see, is a date ranges like <code>08 Feb 2010 00:00 - 15 Feb 2010 00:00</code>, so my result set would look like this:</p>
  
  <pre><code>| day_start           | day_end           | cnt
  ---------------------------------------------------------
  | 08 Feb 2010 00:00   | 15 Feb 2010 00:00 | 55 
  | 15 Feb 2010 00:00   | 22 Feb 2010 00:00 | 76
  | 22 Feb 2010 00:00   | 01 Mar 2010 00:00 | 756
  </code></pre>
  
  <p>Is there any way to do this?</p>