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 |
|
spinningtop
Starting Member
29 Posts |
Posted - 2011-12-16 : 05:31:39
|
| Hi I have an age (int) column from 0-100 and I have a date (date) column, currently NULL. I would like to update the date column with a date incrementing by 1 year. So starting with 01/01/1900 the date column would increment as below up to age 100. I know DATEADD should be used here but I'm not exactly sure how to implement it. age date 0 01/01/19001 01/01/19012 01/01/1902etc....Any help would be appreciated Thanks |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2011-12-16 : 05:39:12
|
| Update table_name set date_column=dateadd(yy,age,'01/01/1900')Senthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
 |
|
|
spinningtop
Starting Member
29 Posts |
Posted - 2011-12-16 : 06:06:17
|
| Great, Thanks SenthilI didn't realize it was so simple. I was expecting to have to use a cursor or while loop or something. |
 |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2011-12-16 : 06:08:00
|
quote: Originally posted by spinningtop Great, Thanks SenthilI didn't realize it was so simple. I was expecting to have to use a cursor or while loop or something.
Welcome Senthil Kumar C------------------------------------------------------MCITP - Database Administration SQL SERVER 2008MCTS - Database Development SQL SERVER 2008 |
 |
|
|
|
|
|