SQLTeam.com | Weblogs | Forums

Date Conversion -1 year


#1

How do I subtract 1 year from a date in YYYY-MM-DD format? Thanks.


#2

SELECT convert(varchar(10),DATEADD(Year,-1,GETDATE()),105)


#3

Is the date stored as char? If so, and you want to be sure it's interpreted correctly, you can use convert coce 120, like so:

SELECT DATEADD(YEAR, -1, CONVERT(date, '2017-03-04', 120))
Naturally replace '2017-03-04' with your actual date column or value.