日期:2014-05-17 浏览次数:20568 次
declare @x varchar(15)
select @x='2013-11-17'
select * from [表名]
where addtime between dateadd(d,-1,@x) and dateadd(s,-1,@x)
declare @x varchar(15)
select @x='2013-11-17'
select dateadd(d,-1,@x) 'begin',dateadd(s,-1,@x) 'end'
/*
begin end
----------------------- -----------------------
2013-11-16 00:00:00.000 2013-11-16 23:59:59.000
(1 row(s) affected)
*/
declare @x varchar(15)
select @x='2013-11-1'
select dateadd(d,-1,@x) 'begin',dateadd(s,-1,@x) 'end'
/*
begin end
----------------------- -----------------------
2013-10-31 00:00:00.000 2013-10-31 23:59:59.000
(1 row(s) affected)
*/
SELECT * FROM TableName
WHERE addtime>=DATEADD(DAY,-1,'2013-11-17')
and addtime <'2013-11-17'