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 |
|
SCHEMA
Posting Yak Master
192 Posts |
Posted - 2009-06-08 : 15:51:51
|
| I have a columnsDate1 Date22006-09-30 2008-06-30 2006-09-30 2009-06-30 How to get :Date1 Date22007-09-30 2008-06-30 2008-09-30 2009-06-30 So Date1 will changed only year part ( Date2 - 1 year). |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-08 : 15:54:41
|
Do you mean this?update tableset date1=dateadd(year,-1,date2) No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
SCHEMA
Posting Yak Master
192 Posts |
Posted - 2009-06-08 : 15:58:39
|
| update tableset year(date1) = year(date2)-1But it doesn't work. |
 |
|
|
SCHEMA
Posting Yak Master
192 Posts |
Posted - 2009-06-08 : 18:06:32
|
Got Answer myself:update tableset date1 = DATEADD(MONTH,3,DATEADD(YEAR,-1,date2)) |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-06-09 : 14:09:26
|
This will work correctly but are you sure the gap in months is always 3? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-06-09 : 14:17:10
|
| update tableset date1 = DATEADD(MONTH,-9,date2) |
 |
|
|
|
|
|