SQL sql查询两次之间的日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7022077/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 11:39:05 来源:igfitidea点击:
sql query where date between two times
提问by Ang
Possible Duplicate:
Specific Time Range Query in SQL Server
For example I have 3 rows:
例如我有 3 行:
Id Date
1 '2011-01-02 09:14:23.0000000'
2 '2011-02-15 10:15:47.0000000'
3 '2011-03-18 21:12:33.0000000'
And I whant to take only rows, where TIME between 09:00 and 11:00 and any date.
而且我只想取行,其中 TIME 介于 09:00 和 11:00 之间以及任何日期。
I need this in result set:
我在结果集中需要这个:
Id Date
1 '2011-01-02 09:14:23.0000000'
2 '2011-02-15 10:15:47.0000000'
Thanks
谢谢
回答by Code Magician
Here's one approach
这是一种方法
SELECT id, date
FROM myTable
WHERE CONVERT(VARCHAR(8),Date,108) between '09:00:00' and '11:00:00'