这是我尝试过的:
SELECT *
FROM attendance
WHERE createdAt between ('2019-04-01 11:00:00' - interval '1 hour')
SELECT *
FROM attendance
WHERE createdAt BETWEEN '2019-04-01 11:00:00' AND
DATE_ADD('2019-04-01 11:00:00', 'INTERVAL 1 hour')
请提供帮助,谢谢。
答案 0 :(得分:0)
像这样吗?
WHERE createdAt >= '2019-04-01 11:00:00' and
createdAt < '2019-04-01 11:00:00' + interval 1 hour
这是MySQL语法,基于您使用的MySQL函数date_add()
。
答案 1 :(得分:0)
interval
语句中不需要引号:
SELECT *
FROM attendance
WHERE createdAt BETWEEN '2019-04-01 11:00:00' AND
DATE_ADD('2019-04-01 11:00:00', INTERVAL 1 hour)