I have a date string in following format 2011-03-07 how to convert this to datetime in python?
Try the following code, which uses strptime
from the datetime module:
from datetime import datetime
datetime.strptime('2011-03-07','%Y-%m-%d')
I note that this (and many other solutions) are trivially easy to find with Google ;)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With