Answer the question
In order to leave comments, you need to log in
How to display records in the timezone from evening to morning of the next day?
Good night everyone, I broke my head, I can’t make a sql query that works with the smalldata type, i.e. 00:00:00 - 23:59:59.
It is necessary to display records in the range from 17:31 to 07:29 (of the next day)
Table columns: TimeFrom, TimeTo ...
SELECT ID, Name, TimeFrom, TimeTo FROM Table WHERE ('17:35:00' BETWEEN TimeFrom and TimeTo)
Answer the question
In order to leave comments, you need to log in
I somehow poorly understood how everything is stored there and what should be displayed.
If the data in the table can be stored in the form:
TimeFrom, TimeTo
1. 17:31:00, 07:29:00
2. 20:34:00, 04:40:00
3. 23:00:00, 07:45: 00
4. 12:00:00, 15:00:00
5. 18:00:00, 23:00:00
, and records like lines 1, 2, 5 should be displayed:
SELECT ID, Название, ВремяОт, ВремяДо
FROM Table
WHERE (ВремяОт > ВремяДо and ВремяОт >= '17:31:00' and ВремяДо <= '07:29:00') /* для обработки 1 и 2 строки */
or (ВремяОт < ВремяДо and (( ВремяОт >= '17:31:00' and ВремяДо <= '23:59:59' ) or ( ВремяОт >= '00:00:00' and ВремяДо <= '07:29:00' )) /* для обработки 5й строки */
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question