This question already has an answer here:
- How to check if the current time is in range in python? 2 answers
I'm trying to check if today's date (in dd-mm-yyyy
format) is in a given range.
My code only checks the day, not the month or year... Could you help me to see what's wrong?
Here it works fine...
import datetime
TODAY_CHECK = datetime.datetime.now()
TODAY_RESULT = ('%s-%s-%s' % (TODAY_CHECK.day, TODAY_CHECK.month, TODAY_CHECK.year))
if '26-11-2017' <= TODAY_RESULT <= '30-11-2017':
print "PASS!"
else:
print "YOU SHALL NOT PASS, FRODO."
But here it doesn't...
import datetime
TODAY_CHECK = datetime.datetime.now()
TODAY_RESULT = ('%s-%s-%s' % (TODAY_CHECK.day, TODAY_CHECK.month, TODAY_CHECK.year))
if '26-11-2017' <= TODAY_RESULT <= '01-12-2017':
print "PASS!"
else:
print "YOU SHALL NOT PASS, FRODO."