Click here to hide categories Click here to show left categories

User: Home          welcome : Guest          Log In / Register here     




Update Only Year in date in sql server with query

I need to update the year only and keep the rest same. Here under is my date format:

2011-03-18 00:35:13.000

Now run below query


UPDATE yourTable 
SET yourDateColumn = DATEADD(year,1,yourDateColumn)
WHERE someColumn = someValue

Example :

update tbuser set CreatedOnDate=DATEADD(year,1,CreatedOnDate) where id='2'

Here in example we tbuser is table name, createdonDate is field name. After executing query, Now the output in table will be 2012-03-18 00:35:13.000

Share this article   |    Print    |    Article read by 7241 times
Author:
Rohit kakria
I am software developer
Related Articles:
Related Interview Questions: