title: python string to datetime, find yesterday then back to string
body: <p>I am trying to do the following:</p>
  
  <ol>
  <li>read a date from a file (the format of the date is %Y-%m-%d)   </li>
  <li>convert a string into a datetime obj (i'm doing this with strptime)  </li>
  <li>get the day <strong>prior</strong> to the datetime </li>
  <li>convert the day prior (look_back) back into a string with a given
  format</li>
  </ol>
  
  <p>Steps 1 &amp; 2 are not an issue, which I accomplish like so:</p>
  
  <pre><code>import datetime
  from datetime import timedelta
  import time
  
  now = datetime.datetime.now() #checks current datetime
  
  ### READ LAST RUN DATETIME ###
  try:
      test = open("last_settings.ini", "r") #opens file in read mode
      print "Name of the file: ", test.name
  
      last_run = test.read(10); # just reads the date
      print "Program was last run: %s" % last_run
      test.close()
      firstRun = 'False'
  except:
      print "Settings file does not exist"
      #test = open("last_settings.ini", "w+") #creates the file
      #test.close()
  
      #first_run = 'True'
      #look_back = str(now-timedelta(days=14)) #sets initial lookBack date of two weeks
      #print "Pulling down all paid invoices from date " + look_back
  
  
  ### 24 hour lookback ###
  look_back = time.strptime(last_run, "%Y-%m-%d")
  </code></pre>
  
  <p>However, every method I've tried for getting the date prior to the give date (#3 above) throws an error.  My code:</p>
  
  <pre><code>look_back = look_back-timedelta(days=1)
  </code></pre>
  
  <p>The error:</p>
  
  <pre><code>look_back = look_back-timedelta(days=1)
  TypeError: unsupported operand type(s) for -: 'time.struct_time' and 'datetime.timedelta'
  </code></pre>
  
  <p>Have ideas about how to do this?</p>