34,575
社区成员
发帖
与我相关
我的任务
分享
--含八点(到九点之前)
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 tb where datepart(hh,getdate())>='22' And datepart(hh,getdate())<=8
select * from [table] where datepart(hh,getdate())>=22 And datepart(hh,getdate())<=8
select * from tb
where convert(varchar(2),[date],108)<='08'
and convert(varchar(2),[date],108)>='22'
select * from tb where datepart(hh,时间字段)>=22 or datepart(hh,时间字段)<=8
select * from [table] where datepart(hh,getdate())>='22' And datepart(hh,getdate())<=8
SELECT * FROM [表名]
WHERE DATEPART(HH,[时间字段名]) BETWEEN 22 AND 24
OR DATEPART(HH,[时间字段名]) BETWEEN 0 AND 7
datepart(hh,col) between 8 and 22
select * from tb where datepart(hh,时间字段)>=10 and datepart(hh,时间字段)<=20