|
发表于 2020-4-12 10:15:01
|
显示全部楼层
create table T(f1 int, f2 datetime)
insert T select 1, '2016-12-20 22:22:32.000'
union all select 2, '2016-12-20 23:32:38.000'
union all select 3, '2016-12-20 00:24:49.000'
union all select 4, '2016/12/28 00:34:11.000'
select f2 from T where
(DATEDIFF(Hour, Convert(char(8),f2,112),f2)=23
and
(DATEDIFF(Minute, Convert(char(10),f2,112),f2)-DATEDIFF(Hour, Convert(char(8),f2,112),f2)*60)
between 0 and 59)
or
(DATEDIFF(Hour, Convert(char(8),f2,112),f2)=0
and
(DATEDIFF(Minute, Convert(char(10),f2,112),f2)-DATEDIFF(Hour, Convert(char(8),f2,112),f2)*60)
between 0 and 30) |
|