Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save pavankjadda/0da5e90589be4ca240c92453ee498bca to your computer and use it in GitHub Desktop.
Save pavankjadda/0da5e90589be4ca240c92453ee498bca to your computer and use it in GitHub Desktop.
Add or Remove years from Date Time in SQL server
  1. Add 5 years to user date of birth timestamp
update user set date_of_birth=dateadd(year, 5, date_of_birth) where datepart(year, date_of_birth)>1965;

  1. Remove 100 years from user date of birth timestamp
update user set date_of_birth=dateadd(year , -100, date_of_birth) where datepart(year, date_of_birth)>2015;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment