title: Select the maximal and minimum dates in the last 3 months
body: <p>in my my mysql table, I have a column with date format: yyyy-mm-dd</p>
  
  <p>I make this request to select the maximum and minimum dates for the last 2 months.</p>
  
  <pre><code>SELECT MIN(date) AS date1, MAX(date) AS date2 FROM mytable
      WHERE (MONTH(date) = (SELECT Month(MAX(date))-1 FROM mytable )
      OR MONTH(date) = (SELECT Month(MAX(date))-2 FROM mytable ))
      AND YEAR(date) = (SELECT YEAR(MAX(date))
      FROM mytable)
  </code></pre>
  
  <p>But when I want to select dates for the last 3 months, I found that I can't make the month Jaunuar-1 
  and also the request :</p>
  
  <pre><code>OR MONTH(date) = (SELECT Month(MAX(date))-3 FROM mytable )
  </code></pre>
  
  <p>don't work !</p>
  
  <p>My question is: How can I select the last 3 Months (or the maximal and minimum dates in the last 3 or 4 or 5 months).</p>
  
  <p>Thanks a lot.</p>