title: mysql query using date of year
body: <p>I have a problem for querying records into mysql</p>
  
  <p>explanation below
  The user could pick a date to assign in variable fromdate and todate</p>
  
  <p>example.</p>
  
  <pre><code>$fromdate = 2008/01/01
  $todate = 2009/10/31
  </code></pre>
  
  <p>In above case, i have to loop and query with the ff:  </p>
  
  <pre><code>SELECT * FROM table where date BETWEEN '2008/01/01' AND '2008/12/31';
  </code></pre>
  
  <p>second loop</p>
  
  <pre><code>SELECT * FROM table where date BETWEEN '2009/01/01' AND '2009/10/31';
  </code></pre>
  
  <p>if <code>$fromdate</code> and <code>$todate</code> is more than one year then I have to limit my query per year. But if less than one year then use <code>$fromdate</code> and <code>$todate</code> in the query.</p>
  
  <p>Thanks in advance</p>
  
  <p>Tirso </p>