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.
| Author |
Topic |
|
satheesh
Posting Yak Master
152 Posts |
Posted - 2012-01-19 : 10:23:14
|
| Dear All,I would like to add 365 days/1 year to startdate to find end datei try to use -> DateAdd(day, 365, startdate).ReturnsStartdate Enddate2011-03-19 - 2012-03-18 2011-02-03 - 2012-02-03DATEADD(yy, 1, startdate) also returns2011-02-03 - 2012-02-03Second one need to be '2012-02-02'.How to modify the above date add function.I need to update all records from 2007 to till date.Any help will be highly appreciated.ThanksReagrds,SG |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
satheesh
Posting Yak Master
152 Posts |
Posted - 2012-01-19 : 10:34:39
|
| Thanks for your reply x002548 I am getting the same error [DATEADD(year, 1, startdate)]Startdate Endate2011-03-19 2012-03-19 Enddate need to be '2012-03-18' Thanks |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2012-01-19 : 10:40:54
|
I don't believe that the result needs to be '2012-02-02' but I belive you meaned 2012-02-03 + 365 should give 2013-02-02 because of the leap year and this happens correct. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
|
|
|