Let\'s say I have a string: \"10/12/13\" and \"10/15/13\", how can I convert them into date objects so that I can compare the dates? For example to see which date is before
Here's one solution using datetime.datetime.strptime:
>>> date1 = datetime.datetime.strptime('10/12/13', '%m/%d/%y') >>> date2 = datetime.datetime.strptime('10/15/13', '%m/%d/%y') >>> date1 < date2 True >>> date1 > date2 False