Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 DateAdd to get last 5 years.

Author  Topic 

niozero
Starting Member

3 Posts

Posted - 2011-03-31 : 10:00:24
I want to write a formula that will give me the last 5 years of a
SELECT. Would this be the correct syntax?


dateadd(year, -4, @startdate)

jimf
Master Smack Fu Yak Hacker

2875 Posts

Posted - 2011-03-31 : 10:06:48
Put in a value for @startDate and see if that gives you what you want.

e.g., select dateadd(year,-4,getdate())

Jim

Everyday I learn something that somebody else already knew
Go to Top of Page
   

- Advertisement -