title: Calculating the time difference between two datetime values in Python
body: <p>I want to compare two date and times with each other and then use that information for other stuff. Like <code>if delta &gt; 23</code> hours do this, <code>elif delta &gt; 11</code> hours, do that etc. I thought this would be a reasonable way to write it, but python won't accept it! It says:</p>
  
  <pre><code>ValueError: 'h' is a bad directive in format '%m/%d/%Y%h:%m:%s'
  </code></pre>
  
  <p>Isn't <code>h</code> the standard way to write hours in Python? :o</p>
  
  <p>My dates are written in this format: "12/28/13 16:49:19", "m/d/y h:m:s" if that's any help!</p>
  
  <pre><code>from datetime import datetime
  date_format = "%m/%d/%Y%h:%m:%s"
  then=(dictionary["date"])
  now= time.strftime("%c")
  a = datetime.strptime(str(then), date_format)
  b = datetime.strptime(str(now), date_format)
  delta = b - a
  print(delta.hour)
  </code></pre>