title: TypeError: can't compare datetime.timedelta to float
body: <p>I'm working on my python script to work out the duration times between start date and end date format like <code>20140520160000</code> and <code>20140520170000</code> so I can get the hour.</p>
  
  <p>I'm having a trouble with this code:</p>
  
  <pre><code>if epgDuration &gt;= 0.10 and epgDuration &lt;= 0.30:
     epgwidth = "250"
  </code></pre>
  
  <p>I get an error when I'm trying to compare the range of the times between 0.10 mins and 0.30 mins.</p>
  
  <p>The error I get is: TypeError: can't compare datetime.timedelta to float.</p>
  
  <p>The error are jumping on this line:</p>
  
  <pre><code>if epgDuration &gt;= 0.10 and epgDuration &lt;= 0.30:
  </code></pre>
  
  <p>Here is the results:</p>
  
  <pre><code>14:44:55 T:1580  NOTICE: 0:30:00
  14:44:55 T:1580  NOTICE: 2:30:00
  14:44:55 T:1580  NOTICE: 3:00:00
  14:44:55 T:1580  NOTICE: 1:00:00
  14:44:55 T:1580  NOTICE: 0:30:00
  14:44:55 T:1580  NOTICE: 0:30:00
  14:44:55 T:1580  NOTICE: 0:30:00
  14:44:55 T:1580  NOTICE: 0:30:00
  14:44:55 T:1580  NOTICE: 0:30:00
  14:44:55 T:1580  NOTICE: 0:30:00
  14:44:55 T:1580  NOTICE: 1:00:00
  14:44:55 T:1580  NOTICE: 0:30:00
  14:44:55 T:1580  NOTICE: 0:30:00
  14:44:55 T:1580  NOTICE: 0:30:00
  </code></pre>
  
  <p>Here is the code when I use to duration the times:</p>
  
  <pre><code>for row in programs:
      program_startdate = str(row[2])
      program_endDate = str(row[3])
  
      try:
         start_date = datetime.datetime.strptime(program_startdate, "%Y%m%d%H%M%S")
         end_date = datetime.datetime.strptime(program_endDate, "%Y%m%d%H%M%S")
      except TypeError:
         start_date = datetime.datetime.fromtimestamp(time.mktime(time.strptime(program_startdate, "%Y%m%d%H%M%S")))
         end_date = datetime.datetime.fromtimestamp(time.mktime(time.strptime(program_endDate, "%Y%m%d%H%M%S")))
  
      #workout the duration times to get the program time
      epgDuration = end_date - start_date
  
      if epgDuration &gt;= 0.10 and epgDuration &lt;= 0.30:
         epgwidth = "250"
  
      elif epgDuration &gt;= 1.00 and epgDuration &lt;= 1.29:
           epgwidth = "500"
      print epgwidth
  </code></pre>