Yesterday I ran across a problem where I had to check to see if a certain file called 'Test' was received within the last two years.
To accomplish this, I used the DATEADD() Function which adds or subtracts a specific time interval from a given date.
DATEADD (datepart, number, date)
The datepart can be broken down by year (yy, yyyy) , quarter (qq, q) , month (mm, m), dayofyear (dy, y), day (dd, d), week (wk, ww), weekday (dw, w), hour (hh), minute (mi, n), and second (ss, s) just to name a few.
If you like this post and want to see more, follow me on my website www.chadcompton.com Or if you prefer...Select * from Table where DocumentType = 'Test'and DateReceived >= DATEADD (yy, -2, GETDATE())