I am trying to compare a date from a text document to the current date to see whether the date in the document has already passed or not.
The code looks something like
'''
from datetime import date
tasks_file = open("tasks.txt", "r", encoding='utf-8')
lines = tasks_file.readlines()
overdue_tasks = 0
for line in lines:
due_date = line.split(",")[4]
if due_date.strip() < date.today().strftime("%d %b %Y"):
overdue_tasks += 1
tasks_file.close()
print(overdue_tasks)
'''
in the tasks.txt file, the date is written as 10 Oct 2022 and the current date is 17 Sep 2022. The issue is that it only compares the 10 to the 17 and therefore concludes that the current date is greater than the due_date.
Is there a way for me to fix this without reformatting the way the date is written in the file?