in reply to Check Time between 2 other times

My guess is that you also have a date field in the database for the record time. If you do, then I would convert the date/time to unixtime and then do the comparison:

use HTTP::Date; my $start_time = str2time('2005-10-01 22:00:00'); my $end_time = str2time('2005-10-02 04:00:00'); my $check_time = str2time('2005-10-01 22:40:00'); if ($start_time < $end_time) { if ($start_time < $check_time and $check_time < $end_time) { print "yes\n"; } else { print "no\n"; } } elsif ($end_time < $start_time) { if ($end_time < $check_time and $check_time < $start_time) { print "yes\n"; } else { print "no\n"; } } else { print "Start and End times are identical\n"; }

For the sake of clarity, I left out retrieving the db times and left them as strings. Also, as others have pointed out, this is easily doable in the db with a simple SQL query:

SELECT 1 WHERE check_time BETWEEN start_time AND end_time or SELECT 1 WHERE concat(check_date, ' ', check_time) BETWEEN concat(star +t_date, ' ', start_time) AND concat(end_date, ' ', end_time)
</code>