Reputation: 115
I want to convert '2011-10-13' to a date object representing the same. I use strptime but it includes the time, which I dont need. How to best avoid this?
d = datetime.datetime.strptime("2011-10-13", "%Y-%m-%d")
print d
2011-10-13 00:00:00
Upvotes: 1
Views: 838
Reputation: 9584
You can use the .date() method:
d = datetime.datetime.strptime("2011-10-13", "%Y-%m-%d")
print d.date()
>> 2011-10-13
Upvotes: 4