How to calculate the number of days between two dates in Python

To calculate the number of days between two dates, you can simply subtract them.

The return will be a timedelta object.

From the timedelta object, call the days property.

from datetime import date

first_day= date(2020,9,22)
second_day = date(2020,6,3)

delta_difference = first_day - second_day
print(f'There are {delta_difference.days} days between {first_day} and {second_day}')
There are 111 days between 2020-09-22 and 2020-06-03

I also recommend the following articles:

Watch This Content