Below snippet return the difference between two dates in number of days.
diff = date1 - date2 days_diff = diff.days
dates_diff_in_no_of_days.py
from datetime import datetime, timedelta
def diff_in_days(date1, date2):
diff = date1 - date2
return diff.days
date2 = datetime(1988, 6, 6)
date1 = datetime.today()
print (diff_in_days(date1, date2))
Output
12157
No comments:
Post a Comment