How to return values only within a specific date range?
I am new to python
My code is:
for report_date in REPORT_DATE_TYPES:
if report_date in result:
date = result[report_date].split(' ')[0]
date = datetime.strptime(date, '%d/%m/%y ')
but I am getting an error:
raise ValueError("time data %r does not match format %r" %
ValueError: time data ’02/03/2022′ does not match format ‘%d/%m/%y ‘
How to fix this?
>Solution :
To point out the year you need to use %Y and also there is an additional space at the end of the format you gave that it’s not present in the date. Try with date = datetime.strptime(date, '%d/%m/%Y')