Click here to Skip to main content
15,886,519 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
i want to update the year in a date,the date is generated by using GETDATE() function
Posted
Comments
Prakash Thirumoorthy 28-Feb-13 4:48am    
question is not detailed.. give more information
vinodkumarnie 28-Feb-13 7:13am    
which year u want to update..?

1 solution

Try something like this
SQL
DECLARE @T TABLE(tDate date)

INSERT INTO @T VALUES ('01-01-2001')

UPDATE @T SET tDate =DATEADD(YEAR, DATEDIFF(YEAR,tDate,GETDATE()),tDate)

SELECT * FROM @T
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900