datetime object and subtraction operator
from datetime import datetime
dateFormat = '%Y-%m-%d'
startDate = datetime.strptime('2022-06-01', dateFormat)
endDate = datetime.strptime('2022-06-10', dateFormat)
diff = endDate - startDate
numberOfWeeks = diff.days // 7
print(numberOfWeeks)
Leave a Comment
Cancel reply