title: how to split the number of days in monthwise between two month
body: <p>hi i want to find the total days of two month and split the days for month wise..for example...
  26-02-2013 to 3-3-2013
  here for the february month it shows 2days leave but march month i wont display the total leave..this is my query..can anyone correct my query..it shows only febraury days only,,march days is not shown here..</p>
  
  <pre><code>SELECT  month(fdate) as Month_Number
          , datename(month, fdate) as Month
          , case when month(fdate) &lt;&gt; month(tdate) then 
              datediff(day, fdate, DATEADD(month, ((YEAR(fdate) - 1900) * 12) + MONTH(fdate), -1)) 
            else 
              datediff(day, fdate, tdate) 
            end as Leaves 
  from    test 
  where   empid like '112'
  </code></pre>