How to calculate the differences between two dates in days with Python

1 Answer

0 votes
import datetime

d1 = datetime.datetime(2021, 5, 7)
d2 = datetime.datetime(2021, 6, 21)

print(abs((d2 - d1).days))




'''
run:

45

'''

 



answered Jun 21, 2021 by avibootz
edited Jun 21, 2021 by avibootz
...