SQLTeam.com | Weblogs | Forums

Date Conversion -1 year

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

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

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.