If I have two dates (ex. \'8/18/2008\'
and \'9/26/2008\'
), what is the best way to get the number of days between these two dates?
from datetime import date
def d(s):
[month, day, year] = map(int, s.split('/'))
return date(year, month, day)
def days(start, end):
return (d(end) - d(start)).days
print days('8/18/2008', '9/26/2008')
This assumes, of course, that you've already verified that your dates are in the format r'\d+/\d+/\d+'
.