title: How do I obtain the delta between two dates?
body: <p>I've been searching around before asking this.</p>
  
  <p>I have Django template, which inputs a water account number, a beginning date, and an ending date. The dates define a search range, and are in mm/dd/yyyy format. </p>
  
  <p>I'd like to convert these dates into a Python format, so I can find the difference between them. I'm aware of date and datetime objects, and I know I can parse -- for example -- 05/01/2012 -- and create a date object from that. </p>
  
  <p>However, I'm interested in a better way to this, like converting the "05/01/2012" directly for start and end date range values, and then taking the delta between those Python date objects.</p>
  
  <p>Thank you.</p>
  
  <p>Edit:
  This is what I'm using to calculate the delta:</p>
  
  <pre><code>d1 and d2 are date strings in the form: mm/dd/yyyy.
  def time_delta(d1, d2):
      dd1   = datetime.strptime(d1, "%m/%d/%Y").date()
      dd2   = datetime.strptime(d2, "%m/%d/%Y").date()
      delta = dd2 - dd1
      return delta.days
  </code></pre>