title: How to get date of a week before from the current system time in Mysql?
body: <p>I have a dropdown box where i select duration. if i select 1 week, i have to retrieve data for the past one week from the Mysql database. i do this with the help of the following query.</p>
  
  <pre><code> SELECT * FROM rpt_machine_log WHERE (timestamp between date_sub(now(),INTERVAL $interval) and now())
  </code></pre>
  
  <p>when i select two weeks, i have to get two result sets, one contains the data of the current week, which can be done with the above query, i also want result set which contains the data for a week before the current week.</p>
  
  <p>similarly, if i select 3 weeks, i should get 3 result set containing data for last 3 weeks, each week as separate result set.</p>
  
  <p>I want to achieve this situation without changing the query, i just want to pass the date range to the query to get the result. Hence i need to fetch the end date for each week from the current system time.</p>
  
  <p><strong>EDITED</strong>
  *<em>EXPLAINED THE SITUATION WITH EXAMPLE:</em>*</p>
  
  <p>if the current day is Tuesday and date is 4-12-2012, when i select 3 weeks, i want record set between these days. 27-11-2012 to 4-12-2012 as one week result set, 20-11-2012 to 27-11-2012 as second week result set and 13-11-2012 to 20-11-2012 as week three result set. is this possible from your query??</p>