title: Count days within a month from date range
body: <p>I have three date ranges in mysql table as follow</p>
  
  <ul>
  <li>from 2013-09-29 to 2013-10-02</li>
  <li>from 2013-10-14 to 2013-10-16</li>
  <li>from 2013-10-28 to 2013-11-05</li>
  </ul>
  
  <p>I want to count only days that occur in Month of October, for example  from first range (2013-09-29 to 2013-10-02) I should get difference of two days (1st and 2nd October) , and it should ignore days from September month, Finally i want to count total days in a given month from above date ranges.</p>
  
  <p>Can it be done from direct mysql query. or any short PHP logic.</p>
  
  <p>here is my table structure 
  id,employee_id,leave_start,leave_to</p>
  
  <p>I am looking for a method some thing like </p>
  
  <p>function countLeaves($employee_id,$month)
  {</p>
  
  <p>// code</p>
  
  <p>return $numberOfLeaves
  }</p>