By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,700 Members | 1,316 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,700 IT Pros & Developers. It's quick & easy.

Date Calculation Previous Years

benchpolo
100+
P: 142
select DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)

Result
------------------------------------------------------
2008-01-01 00:00:00.000

I have the above select statement in SQL to dispay the 1st day of the year, but i'm not able to figure out how to display previous years, in this case, i want to display 2006?

Please advise. Many thanks.
Mar 13 '08 #1
Share this Question
Share on Google+
1 Reply


ck9663
Expert 2.5K+
P: 2,878
select DATEADD(yy, DATEDIFF(yy,0,getdate()), 0)

Result
------------------------------------------------------
2008-01-01 00:00:00.000

I have the above select statement in SQL to dispay the 1st day of the year, but i'm not able to figure out how to display previous years, in this case, i want to display 2006?

Please advise. Many thanks.

Try

Expand|Select|Wrap|Line Numbers
  1. select dateadd(yy,-2,DATEADD(yy, DATEDIFF(yy,0,getdate()), 0))
Mar 13 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.