Обсуждение: SQL Query using time

Поиск
Список
Период
Сортировка

SQL Query using time

От
Karyn Keatley
Дата:
Hi,
I am attempting to write a sql query that compares times on a 24 hr
clock
eg
09:00<16:30 and  21:00>16:30

09:00 is the start time and 16:30 is the end time. The problem is that
if the start time is 23:58 and the end time is 00:30 (next day) is there
any way to carry out this comparison without introducing date.

Is it possible to carry out the comparison in the following manner
select name from table where 00:12 is between 23:58 and 00:30

thanks karyn

Вложения

Re: SQL Query using time

От
Blaise Carrupt
Дата:
> Is it possible to carry out the comparison in the following manner
> select name from table where 00:12 is between 23:58 and 00:30

You could try something like
WHERE ('00:12' BETWEEN startTime AND endTime       AND startTime <= endTime)  OR ('00:12' NOT BETWEEN endTime AND
startTime     AND startTime > endTime)      
 
Should work slower, but should work... And take care to equality with BEWTEEN.


____________
B. Carrupt