Python ProgrammingPython Programming

Python difference between two dates in weeks

from datetime import date

date1 = date(2020, 12, 23)
date2 = date(2021, 5, 11)

days = abs(date1 - date2).days
print(days // 7)
Output
19