I am trying to parse a string date from a CSV in a Jupyter notebook:
from datetime import datetime
print(datetime.strptime('Aug 28, 2022', 'MMM d, yyyy'))
but I get the following error:
ValueError: time data 'Aug 28, 2022' does not match format 'MMM d, yyyy'
What am I doing wrong?
>Solution :
Use other format string (format codes reference):
from datetime import datetime
print(datetime.strptime("Aug 28, 2022", "%b %d, %Y"))
Prints:
2022-08-28 00:00:00