MS SQL删除日期之间的差距超过360天的行

时间:2017-09-15 07:51:22

标签: sql sql-server database

美好的一天

如何删除它们之间有360天差距的行。在第2行和第3行

Table1 
Column1 Column2    Column3 
Fish      Blue      2016-12-14 23:51:25.653    
Dog       Brown     2017-09-14 23:51:25.653 ---  need to be deleted   
Dog       Black     2015-11-14 23:51:25.653 ---  need to be deleted     
Mouse     Red       2017-04-14 23:51:25.653      
Cat       Ping      2017-03-14 23:51:25.653     
Cat       Ping      2017-07-14 23:51:25.653
Mouse     Red       2016-10-14 23:51:25.653

感谢意见

1 个答案:

答案 0 :(得分:0)

你可以这样做:

DELETE FROM [TableName] WHERE DATEDIFF(day,column3, GETDATE()) > 360