I have a function which returns in YYYY-MM-DD i want to add 10 days to this date and check if today is the date. how can i do that.
def date_return:
return YYYY-MM-DD
I have a function which returns in YYYY-MM-DD i want to add 10 days to this date and check if today is the date. how can i do that.
def date_return:
return YYYY-MM-DD
datetime.date.fromisoformat
to turn YYYY-MM-DD into a datetime.date
.datetime.timedelta(days=10)
to add 10 days to that date.datetime.date.today()
.>>> import datetime
>>> yyyymmdd = "2022-09-04"
>>> print(
... datetime.date.fromisoformat(yyyymmdd) + datetime.timedelta(days=10)
... == datetime.date.today()
... )
True