-3

I want to calculate Number of days Between Two Dates using Python Django. Here is my code

In my Html,

<form method='post' action="something">
  <input type="date"  name="firstdate">
  <input type="date" " name="lastdate">
  <input type="submit">
</form>

i am sending this form data to view function,i am getting date overthere in dd-mm-yy formet. and if i print overthere, i am getting firstdate and lastdate in below formet,

2020-01-01 
2020-02-01

i want to calculate number of days between these two dates.How to Do that? i will be thankfull if anyone can help me with this issue.

devid
  • 1
  • 2
  • 3
    Does this answer your question? [How to calculate number of days between two given dates?](https://stackoverflow.com/questions/151199/how-to-calculate-number-of-days-between-two-given-dates) – Lucas Paim Nov 03 '20 at 14:33

1 Answers1

0

Assuming d0 is 2020-01-01 and d1 is 2020-02-01,

delta = d1 - d0
print(delta.days)
fendy3d
  • 363
  • 3
  • 9