I have a dictionary that looks like this and the dates are in string format :-
{ "2021-04-21" : "Shoes",
"2021-04-07" : "Clothes"
"2021-03-19" : "Chocolates"
"2021-03-12" : "Flowers",
"2021-03-03" : "Gloves" }
And the way i am creating my dict is through a list :-
my_order_dictionary = {s[:10]: s[10:] for s in output[1:]}
I am trying to get the values for dates older than 30 days ago from the present day, So i did :-
d = datetime.today() - timedelta(days=30)
for key,value in my_order_dictionary.items():
if (key < d):
print(value)
But i get the following error :-
if (key < d):
TypeError: '<' not supported between instances of 'str' and 'datetime.datetime'
How can i fix the data types and then filter based on date?