How to check if a date is between two dates in python?
EDIT1: In excel, the date that I am reading is 7/13/2018 for example.
How to check if a date is between two dates in python?
EDIT1: In excel, the date that I am reading is 7/13/2018 for example.
You can convert the date so it can be easily compared in Python. Dates 1 and 2 are the converted dates, input_1 and input_2 are the two inputs from Excel. The second parameter passed in is the format in which the date is passed in.
date_1 = datetime.strptime(input_1, '%d/%m/%Y')
date_2 = datetime.strptime(input_2, '%d/%m/%Y')
date_3 = date(2017, 7, 19)
Now that you have the dates in the right format, I will check if date_3 falls within date_1 and date_2. This will return a Boolean.
date_1 < date_3 < date_2