Click here to Skip to main content
14,636,152 members
Rate this:
Please Sign up or sign in to vote.
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

Rate this:
Please Sign up or sign in to vote.

Solution 1

Try something like this
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
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100