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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 update table set date_field = date_field + 365

Author  Topic 

ryguy
Starting Member

2 Posts

Posted - 2007-11-14 : 23:27:10
update table set date_field = date_field + 365

I am using the above sql to update date fields in tables forward a year, but I have found this causes a display issue with the data fed into a web page.

Is there another method I should use?

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-14 : 23:28:44
[code]update table set date_field = dateadd(year, 1, date_field) [/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

ryguy
Starting Member

2 Posts

Posted - 2007-11-15 : 07:58:31
Thanks for the reply - is there a way to 'fix' the columns i have already updated?
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-15 : 08:02:27
just reversed it with minus sign
 update table set date_field = date_field - 365 



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2007-11-15 : 08:03:09
If you have new records inserted between now and then, you need to take care of those records separately.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -