DateDiff在7天内

时间:2017-12-13 00:27:59

标签: sql tsql date datediff

我做错了什么?我正在寻找任何记录,其中snf.StartDate是在inp.enddate之后7天或更短的时间。

和DATEDIFF(day,inp.Discharge_Date,snf。[StartDate])< = 7

3 个答案:

答案 0 :(得分:0)

你可以试试这个:

and ABS( DATEDIFF(day, inp.Discharge_Date, snf.[StartDate]) ) <= 7

答案 1 :(得分:0)

这样做......

SELECT DATEDIFF(day,StartDate, EndDate) As DateDiff
FROM dbo.DoesntMatter
Where DATEDIFF(day,StartDate, EndDate) between -7 and 0

答案 2 :(得分:0)

SELECT Column1,Column2
FROM Table_ABC
Where DATEDIFF(day,add_on, getdate()) > 7  order by add_on asc