Skip to content Skip to sidebar Skip to footer

Unable To Solve Strptime() Issue Even After Trying All The Formats

I'm using the following code: data['Input_volTargetStart'][1]>time.strptime(data['Dates'][1], '%d %b $y') When I try to run it, I get this error: ValueError: time data '04-Jun

Solution 1:

You can actually put the dashes ('-') as part of the format, i.e "%d-%b-%y".

Solution 2:

This is what you'll need.

from datetime import datetime

a = "04-Jun-99"
frmt = datetime.strptime(a, "%d-%b-%y")
print(frmt)

>>1999-06-0400:00:00

Implement that example into your code to get proper output.

Post a Comment for "Unable To Solve Strptime() Issue Even After Trying All The Formats"