Skip to content
Advertisement

Date comaprison in python attribute error

I have a date stored in a text file in this format "19 May 2021", I want to compare this date to the today’s date to see if we have reached this date or not (> / <) comparisons. I was instructed to first convert this string date to a date object, I am failing to do so.

For overdue_tasks in task_overview:

JavaScript

This is the error I get:

JavaScript

Advertisement

Answer

The strptime() method is from datetime.datetime, not datetime.time. See the documentation for datetime.datetime.strptime().

So you’ll simply need to change

JavaScript

to

JavaScript
User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement