CREATE TABLE my_table (
created_time DATETIME
);
INSERT INTO my_table VALUES ('2018-04-01 14:00:00');
INSERT INTO my_table VALUES ('2018-04-01 14:50:00');
INSERT INTO my_table VALUES ('2018-04-04 10:00:00');
INSERT INTO my_table VALUES ('2018-04-01 15:00:00');
查询
select * from my_table
where
(created_time between '2018-04-01' and '2018-04-30')
AND
(CAST(created_time AS time) > CAST('14:30:00' AS time) AND CAST(created_time AS time) < CAST('16:30:00' AS time))
1条答案
按热度按时间iqxoj9l91#
你需要分开比较
Date
价值与Time
价值观。您可以尝试此查询。
测试DLL
查询
[结果]:
sqlfiddle公司