title: Difference between two dates in Python
body: <p>I have two different dates and I want to know the difference in days between them. The format of the date is YYYY-MM-DD.</p>
  
  <p>I have a function that can ADD or SUBTRACT a given number to a date:</p>
  
  <pre><code>def addonDays(a, x):
     ret = time.strftime("%Y-%m-%d",time.localtime(time.mktime(time.strptime(a,"%Y-%m-%d"))+x*3600*24+3600))      
     return ret
  </code></pre>
  
  <p>where A is the date and x the number of days I want to add. And the result is another date.</p>
  
  <p>I need a function where I can give two dates and the result would be an int with date difference in days.</p>