Comparing two date strings in Python
Use datetime.datetime.strptime
:
>>> from datetime import datetime as dt
>>> a = dt.strptime("10/12/13", "%m/%d/%y")
>>> b = dt.strptime("10/15/13", "%m/%d/%y")
>>> a > b
False
>>> a < b
True
>>>
If you like to use the dateutil
and its parser:
from dateutil.parser import parse
date1 = parse('10/12/13')
date2 = parse('10/15/13')
print date1 - date2
print date2 > date2