I have a table with a list of dates of datetime format in two columns.
Now what I would like to do is pull each non null date from Column1, add one year to each value and then store it into Column2.
So below, after the update, Column2 (the one with the nulls) will show:
2014-07-09 00:00:00.000
2013-07-30 00:00:00.000
2013-10-19 00:00:00.000
2013-10-19 00:00:00.000

How does the syntax go? Do I need to do a select followed by an update?
You can use DATEADD
UPDATE YourTable
SET Column2 = DATEADD(YEAR, 1, Column1)
WHERE Column1 IS NOT NULL
UPDATE tbl
SET Column2 = DATEADD(year, 1, Column1)
WHERE Column2 IS NULL AND Column1 IS NOT NULL
That's gone to be ok
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With