SQL!急急急
取出昨天以前的数据,且日期的时分秒在23点之前的。急急急!。忘高手指教
[解决办法]
select *from date < getdate()-1 and datepart(hh,date) < 23
[解决办法]
--取出昨天以前的数据,且日期的时分秒在23点之前的。急急急!。忘高手指教
create table #t(
id int identity(1,1),
dtime datetime
)
insert #t
select '2012-02-11 13:23:06' union all
select '2012-02-10 11:23:06' union all
select '2012-01-19 23:23:06' union all
select '2012-01-18 13:23:06' union all
select '2012-02-09 20:23:06' union all
select '2012-02-11 10:23:06'
select *from #t where dtime<GETDATE()-1 and DATEPART(hh,dtime) < 23
/*
iddtime
22012-02-10 11:23:06.000
42012-01-18 13:23:06.000
52012-02-09 20:23:06.000
*/