Program - Calculate difference in days between two dates


Topic: Program - Calculate difference in days between two dates

Solution

def days_between(d1, d2):
    from datetime import datetime as dt
    f_date = dt.strptime(d1, "%d/%m/%Y").date()
    l_date = dt.strptime(d2, "%d/%m/%Y").date()
    delta = l_date - f_date
    print(delta.days)



List all Python Programs