I have strings like Jan 25, 2021
(Jan,Feb,Mar,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec) how can I convert it to 2021-01-25
?
I was defining a function like:
def to_datetime(datestring):
#date = datetime.strptime(datestring, '%m.%d.%Y')
#return date.strftime("%Y-%m-%d")
return datetime.strptime(datestring, '%Y-%m-%d')
The issue are the month words so maybe I can replace the string to month number and then convert it but I am stuck
datetime.strptime('Jan 25, 2021', '%b %d, %Y').strftime('%Y-%m-%d')
? – accdias