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
 Transact-SQL (2000)
 Update date/time

Author  Topic 

poser
Posting Yak Master

124 Posts

Posted - 2006-10-18 : 14:36:37
Hi
I hope you all will be able to help me...

I have a Time table

pp(date/time)
9/30/2006

I want to run a sproc against this so that every year on this date it will increase this date to 9/30/2007 then the next year to 9/30/2008 etc....

Any easy way to do this?

Thanks for your help
P

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2006-10-18 : 14:41:54
this simply sounds like poor design. WHY would you want to do this?

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2006-10-18 : 14:43:42
I'm not sure from your description exactly which rows you want to update - this will add one year to the column for all rows that have the date equal to todays date.

UPDATE pp SET dtcol = DATEADD(YY, 1, dtcol)
WHERE CONVERT(varchar(10), dtcol, 101) = CONVERT(varchar(10), getdate(), 101)
Go to Top of Page

poser
Posting Yak Master

124 Posts

Posted - 2006-10-18 : 16:47:50
Yes this is a poor design, but unfortunately we sometimes have to work with what we inherit.
Thanks for trying to help
R/P
Go to Top of Page
   

- Advertisement -