You can use time
from datetime
to make timeobjects. So you can create a time object for your start time and a time object for your end time. then you can just extract the timeobject from you datetime and compare it with a simple between expression. I have used timedelta, to just manipulate the current date time to show this working.
from datetime import datetime, timedelta, time
datetimes = []
datetimes.append(datetime.now())
datetimes.append(datetimes[-1] + timedelta(hours=3, minutes=20))
datetimes.append(datetimes[-1] + timedelta(hours=3, minutes=20))
start_time = time(14, 30)
end_time = time(16, 30)
for current in datetimes:
print(f"Time: {current.hour:02}:{current.minute:02}")
if start_time <= current.time() <= end_time:
print("afternoon")
else:
print("not afternoon")
OUTPUT
Time: 11:22
not afternoon
Time: 14:42
afternoon
Time: 18:02
not afternoon