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 2005 Forums
 Transact-SQL (2005)
 Changing a Date in Table

Author  Topic 

martinhogan
Starting Member

5 Posts

Posted - 2012-01-13 : 08:20:39
HI,
I have a database with Date field that needs to be changed from
1975 to 2011. Problem is, I only want to change the year, a not
the day and month.

In short change 1975\09\05 to 2011\09\05
1975\09\06 to 2011\09\06

Please help
Thanks

Martin Hogan

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2012-01-13 : 08:25:06
UPDATE dbo.Table1
SET Col1 = DATEADD(YEAR, 36, Col1)
WHERE Col1 >= '19750101' AND Col1 < '19760101'



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

martinhogan
Starting Member

5 Posts

Posted - 2012-01-13 : 08:31:30
Sheez, thanks SwePezo, after spending a whole day,
you solved it for me in a minute.

Tried and it worked. Thanks a mil.


Martin Hogan
Go to Top of Page
   

- Advertisement -