Write a program to Calculate number of days between two given dates


Topic: Write a program to Calculate number of days between two given dates

Solution

from datetime import datetime
date_1 = datetime(2020, 2, 25).date()
date_2 = datetime(2020, 9, 17).date()
delta = None
if date_1 > date_2:
    delta = date_1 - date_2
else:
    delta = date_2 - date_1
print("Difference is", delta.days, "days")



List all Python Programs