22,301
社区成员




SELECT * FROM A WHERE B>='2014-07-30 00:00:00' AND B<='2014-07-30 23:59:59'
CREATE TABLE #tmp (dt SMALLDATETIME)
INSERT INTO #tmp(dt) VALUES('2014-07-30 23:59:00'),('2014-07-30 23:59:59'),('2014-07-31 00:00:00'),('2014-07-31 00:00:29')
,('2014-07-31 00:00:30')
SELECT * FROM #tmp WHERE dt>='2014-07-30 00:00:00' AND dt<='2014-07-30 23:59:59'
create table A(B smalldatetime)
insert into A(B)
select '2014-07-31 00:00:00' union all
select '2014-07-30 00:00:00' union all
select '2014-07-29 00:00:00'
select *
from A
where B>=cast('2014-07-30 00:00:00' as datetime)
and B<=cast('2014-07-30 23:59:59' as datetime)
/*
B
-----------------------
2014-07-30 00:00:00
(1 row(s) affected)
*/