select * from tb where datepart(hh,时间字段)>=10 and datepart(hh,时间字段)<=20
datepart(hh,col) between 8 and 22
SELECT * FROM [表名] WHERE DATEPART(HH,[时间字段名]) BETWEEN 22 AND 24 OR DATEPART(HH,[时间字段名]) BETWEEN 0 AND 7
select * from [table] where datepart(hh,getdate())>='22' And datepart(hh,getdate())<=8
select * from tb where datepart(hh,时间字段)>=22 or datepart(hh,时间字段)<=8
select * from datepart(hh,时间字段) between 8 and 22
select * from tb where convert(varchar(2),[date],108)<='08' and convert(varchar(2),[date],108)>='22'
select * from [table] where datepart(hh,getdate())>=22 And datepart(hh,getdate())<=8
select * from tb where datepart(hh,dt) between 22 and 24 or datepart(hh,dt) between 0 and 8select * from tb where datepart(hh,dt) between 22 and 23 or datepart(hh,dt) between 0 and 7
select * from tb where datepart(hh,getdate())>='22' And datepart(hh,getdate())<=8
--含八点(到九点之前) select * from tb where datepart(hh,dt) between 22 and 24 or datepart(hh,dt) between 0 and 8 --不含八点 select * from tb where datepart(hh,dt) between 22 and 24 or datepart(hh,dt) between 0 and 7
取昨晚10:00到今早8:00的数据 select * from [表名] where datepart(hh,getdate()-1)>='22' And datepart(hh,getdate())<=8
WHERE DATEPART(HH,[时间字段名]) BETWEEN 22 AND 24
OR DATEPART(HH,[时间字段名]) BETWEEN 0 AND 7
select * from tb where datepart(hh,时间字段)>=22 or datepart(hh,时间字段)<=8
where convert(varchar(2),[date],108)<='08'
and convert(varchar(2),[date],108)>='22'
select * from tb where datepart(hh,dt) between 22 and 24 or datepart(hh,dt) between 0 and 8 --不含八点
select * from tb where datepart(hh,dt) between 22 and 24 or datepart(hh,dt) between 0 and 7
select * from [表名] where datepart(hh,getdate()-1)>='22' And datepart(hh,getdate())<=8