F.M.F.
F.M.F.

Reputation: 2310

Python: Datetime, Error with strftime

I try to convert a time string to a date time object, but it alway throws the following error:

ValueError: time data '2016-04-07 06:34:39' does not match format '%Y-%m-%w %H:%M:%S'

Whats the problem?

Upvotes: 0

Views: 822

Answers (1)

Thaian
Thaian

Reputation: 1245

I think error is in your datetime format where you have %w what means " Weekday as a decimal number, where 0 is Sunday and 6 is Saturday." and fail when you have your day greather than 6 :)

'2016-04-07 06:34:39' format '%Y-%m-%w %H:%M:%S'

Change %w to %d:

'%Y-%m-%d %H:%M:%S'

Let me know if that help you.

Python datetime docs

Upvotes: 4

Related Questions