in reply to Check Time between 2 other times

I realise it's not a Perl answer, but if you're getting the record from a database you may find that the database engine can do this work for you.
AFAIK, all the major platforms include functions to allow you to compare, add and subtract dates/times.
A simple query like
select 1 where $my_date_time > $start_date_time and $my_date_time < $end_date_time
might be sufficient.
If your database record stores only times, not dates/times, you might get some mileage from looking into your database platform's commands for adding hours/minutes to the current time.

A second, perhaps equally unhelpful suggestion:
As you've doubtless discovered, 22:40 may or may not be between 22:00 and 04:00, depending on whether or not you infer 'on the same day'. If it's within your power to do so, perhaps it might be a good idea to alter the way the start/end times are stored in the database - perhaps storing the start time in conventional 24h clock notation(22:00), but then showing the duration of the task by specifiying a number of minutes (or hours, or nanoseconds - whatever unit suits best) after the start.
So, instead of
start | end ----------- 22:00 | 04:00
you'd have
start | end_after_minutes ---------------- 22:00 | 360
Not only would it then be straightforward to calculate the start and end datetime values in the database (and so carry out the comparison you're after), but you'd also be able to specify tasks which last for more than 24 hours.

Replies are listed 'Best First'.
Re^2: Check Time between 2 other times
by Aristotle (Chancellor) on Nov 03, 2005 at 14:23 UTC
    select 1 where $my_date_time > $start_date_time and $my_date_time < $end_date_time

    That’s un-SQLish. It can be better written as

    SELECT 1 WHERE $my_date_time BETWEEN $start_date_time AND $end_date_time

    (And of course, you’d pass the values in using placeholders, not by interpolating them into the SQL.)

    Makeshifts last the longest.

      Absolutely, on both points. I was trying to make the logic as clear as possible for the OP.

      (also, I'm not sure whether all SQL dialects support BETWEEN)

        It’s part of SQL92, at least. MySQL, PostgreSQL, SQLite and Oracle support it. I’d be surprised if any common RDBMS does not.

        Makeshifts last the longest.