本文介绍了在SQL 10PM中选择日期和时间,每天6AM之前的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
SELECT scandate from FPI where scandate BETWEEN '2017-07-20' and '2017-07-25' DATEPART(hh,[scandate]) >= 22 AND DATEPART(hh,[scandate]) < 6
但我什么也没得到...
but i get nothing ...
SELECT scandate from FPI where scandate BETWEEN '2017-07-20' and '2017-07-25' DATEPART(hh,[scandate]) >= 14 AND DATEPART(hh,[scandate]) < 22
下午2点至10点正在工作,但晚上10点至6点则无法工作... TIA
2pm to 10pm is working but for 10pm to 6am its not working...TIA
推荐答案
在第一个查询中,您需要 OR
:
You need OR
in the first query:
SELECT scandate
FROM FPI
WHERE scandate BETWEEN '2017-07-20' and '2017-07-25' AND
(DATEPART(hour, scandate) >= 22 OR DATEPART(hour, scandate) < 6)
这篇关于在SQL 10PM中选择日期和时间,每天6AM之前的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!