SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Changing a Date in Table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

martinhogan
Starting Member

South Africa
5 Posts

Posted - 01/13/2012 :  08:20:39  Show Profile  Reply with Quote
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

Sweden
29156 Posts

Posted - 01/13/2012 :  08:25:06  Show Profile  Visit SwePeso's Homepage  Reply with Quote
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

South Africa
5 Posts

Posted - 01/13/2012 :  08:31:30  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000