|
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'
declare @ t1 char (5), @ t2 char (5)
set @ t1 = '23: 30 '
set @ t2 = '00: 30 '
select * from T
where f2 between (convert (char (10), f2, 120) + '' + @ t1) and (convert (char (10), f2 + 1, 120) + '' + @ t2)
--result
f1 f2
----------- --------------------------------------- ---------------
2 2016-12-20 23: 32: 38.000
(1 row (s) affected) |
|