sqlite查找两次之间的时间问题与午夜时间
我在桌上有两次——开门时间和关门时间sqlite查找两次之间的时间问题与午夜时间,sqlite,datetime,time,Sqlite,Datetime,Time,我在桌上有两次——开门时间和关门时间 Open_time. Selected time Close_time 06:00:00 09:23:46 23:45:00 09:00:00 09:23:46 00:00:00 09:00:00 09:23:46 23:00:00 09:00:00 09:23:46 23:00:00 06:00:00 09:23:46 23:45:00 06:00:00 0
Open_time. Selected time Close_time
06:00:00 09:23:46 23:45:00
09:00:00 09:23:46 00:00:00
09:00:00 09:23:46 23:00:00
09:00:00 09:23:46 23:00:00
06:00:00 09:23:46 23:45:00
06:00:00 09:23:46 04:00:00
06:00:00 09:23:46 02:00:00
我只需要选择打开和关闭之间的时间,但是我的表达式
我有一些问题
SELECT open_from, close_at FROM restrnt WHERE (time('now', '+10 hours') BETWEEN restaurants.open_from and restaurants.close_at)
06:00:00 23:45:00
09:00:00 23:00:00
09:00:00 23:00:00
06:00:00 23:45:00
它只选择00:00:00之前的时间,但我需要它在该片段中找到。如果您的时间戳包含日期,可能会容易得多。这是个好主意,但它喜欢无法存储日期的常量数据。
SELECT time('now','+5 hours') as nowTime, time(restaurants.open_from) as openTime, time(restaurants.close_at) as closeTime,
CASE
WHEN time(restaurants.open_from) > time(restaurants.close_at) THEN time('now','+5 hours') >= time(restaurants.open_from) or time('now','+5 hours') < time(restaurants.close_at)
when time(restaurants.open_from) < time(restaurants.close_at) THEN time('now','+5 hours') >= time(restaurants.open_from) and time('now','+5 hours') < time(restaurants.close_at)
END is_opened
from restaurants
WHERE is_opened >0
06:16:03 06:00:00 23:45:00 1
06:16:03 06:00:00 23:45:00 1
06:16:03 06:00:00 04:00:00 1
06:16:03 06:00:00 02:00:00 1