Skip to content

Instantly share code, notes, and snippets.

@ramons03
Last active January 11, 2017 14:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ramons03/facb1a37aa30a5206096104ae724a6f9 to your computer and use it in GitHub Desktop.
Save ramons03/facb1a37aa30a5206096104ae724a6f9 to your computer and use it in GitHub Desktop.
Change Year only to a date column in SQL.
--SQL Server
UPDATE table SET DateToModify = DATEADD(YEAR, -1, DateToModify)
where YEAR(DateToModify) = 2015
--MySQL
UPDATE table SET DateToModify = DATE_ADD(DateToModify, INTERVAL 1 YEAR)
where YEAR(DateToModify) = 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment