SQLTeam.com | Weblogs | Forums

I had one joining date query question


I have to find employee records who have completed 100 days since their joining


What have you tried?


FROM dbo.emps
WHERE join_date < DATEADD(DAY, DATEDIFF(DAY, 0, GETDATE()) - 100, 0)


Yes, this also worked. I had tried this way and it was also SELECT EmpName, EMPID FROM Employee

Thank you for your correct and useful query btw.


This method won't use an index on JOININGDATE because the use of that column within a function is not SARGable, and thus will be inefficient, so preferable to do it Scott's way.