title: Find the difference between 2 dates in Python
body: <p>I am attempting to use Python to work out the difference between 2 dates.</p>
  <p>Currently my code is as follows</p>
  <pre><code>elif request.method == 'POST':
      name = request.form['name']       #Pulls name from html form
      rawstartdate = request.form['date1']   #Pulls First date from html form
      rawenddate = request.form['date2']    #Pulls End date from html form
      datetimeobject = datetime.strptime(rawstartdate, '%Y-%m-%d')
      startdate1 = datetimeobject.strftime('%d-%m-%Y')   #Change First date to UK format
      datetimeobject2 = datetime.strptime(rawenddate, '%Y-%m-%d')
      enddate1 = datetimeobject2.strftime('%d-%m-%Y')   #Change End date to UK format
      a = datetime.strptime(startdate1, date_format)
      b = datetime.strptime(enddate1, date_format)
      delta = b - a
      duration=(delta.days) #Calculate difference in days between Variables
      print(duration) # for debugging
      record = database(user=name,startdate=startdate1,enddate=enddate1,duration=duration)
  </code></pre>
  <p>In the code, I fetch the Dates from the Datepicker from the front end website. This is by default passed to Python in Year-Month-Date. I convert this to the standard UK date format before inserting into my database for storage.</p>
  <p>The issue i am having is the datatime function of &quot;.days&quot; is returning an incorrect value.</p>
  <p>For example if the dates are &quot;20-10-2021&quot; To &quot;21-10-2021&quot;. The program is returning &quot;1&quot; I am expecting the program to return &quot;2&quot; as there are 2 days between the dates &quot;20th&quot; and &quot;21st&quot;.</p>
  <p>Is there something I am missing here ?</p>