title: Xpath/xQuery difference in months
body: <p>I am trying to get the difference between two dates in months for an xPath. </p>
  
  <p>I have no problems getting it in days (1127)</p>
  
  <pre><code>days-from-duration(xs:date('2012-06-17')-xs:date('2009-05-17'))  
  </code></pre>
  
  <p>When I try doing it in months I get 0</p>
  
  <pre><code> months-from-duration(xs:date('2012-06-17')-xs:date('2009-05-17')) 
  </code></pre>
  
  <p>I did notice that this comes back as days only ("P1126D") so that maybe the problem just not sure how to fix it.</p>
  
  <pre><code> xs:date('2012-06-17')-xs:date('2009-05-17')
  </code></pre>
  
  <p>Thanks for any help!</p>
  
  <p>So the best thing I can seem to do is manually calculate it.</p>
  
  <pre><code>(year-from-date(xs:date('2012-06-17')) - year-from-date(xs:date('2012-05-18')))*12 + month-from-date(xs:date('2012-06-17')) -month-from-date(xs:date('2012-05-18')) + (if (day-from-date(xs:date('2012-06-17'))  &lt; day-from-date(xs:date('2012-05-18')) ) then -1 else 0)
  </code></pre>