skip to Main Content

i have a table with time slots, one column with start time, one colun with end time, 12 slots time per day, example :

start end value
101 230 10
231 400 11
401 500 12
2216 100 9

integer in column ‘start’ and column ‘end’ are time in 24h format. ex : 2216 = 22:16

In this example, is it possible to select value where time is 00:02 (so value 9, 00:02 is between 22:16 and 01:00) ?

i try :

SELECT value FROM table WHERE '2' BETWEEN 'start' AND 'end'

without success when the time slot sought overlaps…
Column must be in time format instead of integer for this query ?

Thanks !

2

Answers


  1. Chosen as BEST ANSWER

    The good query is :

    SELECT value FROM table WHERE ((start > end AND '2' <= end) OR ('2' >= start AND '2'<= end));

    Thanks @P.Salmon


  2. SELECT value FROM table WHERE start < 2 AND end > 2
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search