I am trying to check if one datetime lies between two datetimes, most of the cases return true, but in below case it return false whereas it should return true, how can I check it in proper way.
time1=1900-01-01 08:30:00
time2=1900-01-01 00:00:00
inbetween=1900-01-01 20:00:00
if (time1<=inbetween<=time2): # if 12 hour format (8:30AM<8:00PM<12:AM) it should be true
print("True")
return True
else:
print("False")
return False
in above case inbetween lies between time1 and time 2 so it should return True but it return False. How can I check. NOTE: the date will always remain same so I have to check it on the time basis.