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
 how to get 20 years from current year

Author  Topic 

swati.yadav
Starting Member

1 Post

Posted - 2014-09-30 : 07:59:31
Hi,
I want an sql query that wil give me listing of 20 years from current year.
Please send me an sql query asap.

Thanks

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2014-09-30 : 08:13:06
Is this?

select year(getdate())+number from master..spt_values
where type='p' and number between 1 and 20

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

junior6202
Starting Member

45 Posts

Posted - 2014-10-01 : 11:59:07
This should be an easy was to go back to 20 yrs BETWEEN DATEADD(DD, - 7300, GETDATE()) AND GETDATE()
Go to Top of Page
   

- Advertisement -