Hi,
Can some one tell me the best way to find the difference between two dates. I got a table with dates. I need to filter records with dates older than 3 years from today. This calculation should take leap years in to account as well.
Many Thanks
Regards,
-VJ
use the datediff...
Datediff(YY,YourColumn,Getdate()) >3
Sample,
Code Snippet
Create Table #data (
[dates] Varchar(100)
);
Insert Into #data Values('1/1/2000');
Insert Into #data Values('1/1/2005');
Insert Into #data Values('12/4/1999');
Insert Into #data Values('12/3/2006');
Select
*
from
#Data
Where
datediff(yy, dates, getdate()) > 3
No comments:
Post a Comment