title: How to convert a DateTime object to hours in python?
body: <p>I am trying to subtract the date values that are contained in separated lists and store only the results that are less than 24 hours and convert them into hours. This is the code I have so far:</p>
  
  <pre><code>#stored lists of dates
  
  closure_date = ['2017-06-13 11:00:00', '2017-06-09 11:00:00', '2017-06-02 11:00:00']
  opening_date = ['2017-06-13 05:00:00', '2017-06-09 05:00:00', '2017-06-02 05:00:00']
  
  results = []
  
  #Subtract the dates
  results.append([datetime.strptime(c,'%Y-%m-%d %H:%M:%S') - datetime.strptime(o,'%Y-%m-%d %H:%M:%S') for c, o in zip(closure, opening) if datetime.strptime(c,'%Y-%m-%d %H:%M:%S') - datetime.strptime(o,'%Y-%m-%d %H:%M:%S')&lt;timedelta(hours=24)])
  </code></pre>
  
  <p>The result I get is a double list with the results that are less than 24 hours in seconds format.</p>
  
  <pre><code>[[datetime.timedelta(0, 21600), datetime.timedelta(0, 21600)]]
  </code></pre>
  
  <p>One approach I tried was to get those seconds from the results list and then divide each result by 3600 to get the hours format, something like:</p>
  
  <pre><code>for r in results:
      hour.append(r.datetime.timedelta(days=1).total_seconds()/3600)
  </code></pre>
  
  <p>But this is not possible because I get the error <strong>AttributeError: 'list' object has no attribute 'datetime'</strong> which is reasonable since the results are in a double list and I would need another index to extract each result from the most inner list, IMO not simple to manipulate and I am sure there is a better way to accomplish this goal. </p>
  
  <p>How can I obtain the seconds into hours from the double list in a better and simplistic way to manipulate later for doing other arithmetic calculations? </p>