title: Python: Difference of 2 datetimes in months
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4039879/best-way-to-find-the-months-between-two-dates-in-python">Best way to find the months between two dates (in python)</a>  </p>
  </blockquote>
  
  
  
  <p>I would like to know how I can have the exact number of months for this difference:</p>
  
  <pre><code>date1 = datetime.strptime(str('2011-08-15 12:00:00'), '%Y-%m-%d %H:%M:%S')
  date2 = datetime.strptime(str('2012-02-15'), '%Y-%m-%d')
  </code></pre>
  
  <p>date2-date1 results in</p>
  
  <pre><code>datetime.timedelta(183, 43200)
  </code></pre>
  
  <p>I would like to know the exact number of months, in this case it should return <strong>5</strong> and not 6 (because of the hour)</p>