I'm trying to convert a string date_str = '01-01-2000' to a date object, and want to compare with a given date.
I used my_date = datetime.datetime.strptime(date_str, "%d-%m-%Y") which works, until I try to compare with a given date:
if my_date <= other_date:
TypeError: can't compare datetime.datetime to datetime.date
When I change datetime to date and do datetime.date.strptime(date_str, "%d-%m-%Y"), I get AttributeError: type object 'datetime.date' has no attribute 'strptime':
datetime.date.strptime(date_str, "%d-%m-%Y")
Traceback (most recent call last):
File "<input>", line 1, in <module>
AttributeError: type object 'datetime.date' has no attribute 'strptime'