日期:2014-05-18 浏览次数:20578 次
declare @t table(col datetime) insert into @t select '2012-01-31 19:37:57.450' union all select '2012-01-31 11:40:57.450' union all select '2012-01-31 11:39:57.450' union all select '2012-01-31 11:39:58.450' union all select '2012-01-31 11:37:57.450' union all select '2012-01-31 11:41:57.450' union all select '2012-01-31 11:42:57.450' --得到8小时以前的数据 select * from @t where datediff(hh,col,getdate())>=8 /* col ----------------------- 2012-01-31 11:40:57.450 2012-01-31 11:39:57.450 2012-01-31 11:39:58.450 2012-01-31 11:37:57.450 2012-01-31 11:41:57.450 2012-01-31 11:42:57.450 */ --得到480分钟以前的数据 select * from @t where datediff(mi,col,getdate())>=480 /* col ----------------------- 2012-01-31 11:40:57.450 2012-01-31 11:39:57.450 2012-01-31 11:39:58.450 2012-01-31 11:37:57.450 2012-01-31 11:41:57.450 */
------解决方案--------------------
Delete From Car WHERE datediff(mi,carDate,getdate())>= (8 * 60)
------解决方案--------------------
delete from tbl where datediff(mi,carDate,getdate())>= 480