Not necessarily the cause of your problem, but if you're going to compare dates it should be as objects, or as text as year-month-day. Here you're comparing dates as text in day-month-year format. So January first 9999 comes before May 4th 2020
"01-01-9999" < "04-05-2020" ... 04-05-2020 09:30:00 40 04-05-2020 12:30:00 40 04-05-2020 15:30:00 40 04-05-2020 22:30:00 40 ... input_date,input_time,input_duration=date_time_duration.split(' ') current_datetime = datetime.datetime.now() current_date = current_datetime.strftime('%d-%m-%Y') if(input_date>=current_date): while(True): ... -- https://mail.python.org/mailman/listinfo/python-list