SQL dates returns 12/20/18 when it should be 12/20/17

Any help would be appreciated. it works for 2/10/18, 3/10/18 but not 4/10/18 This is to get a date range for a report that runs every month on the 10th for all accounts that are 75 day past due and not reported on last month report

DECLARE @TODAYS_DT DATE = '4/10/2018'

DECLARE @START_DT CHAR(10)
DECLARE @END_DT   CHAR(10)

SELECT  
    @START_DT = CONVERT(VARCHAR, DATEPART(MM, DATEADD(MM, -1, DATEADD(DAY, -75, '4/10/2018')))) + '/20/' + CONVERT(VARCHAR, DATEPART(YEAR, DATEADD(DAY, -75, '4/10/2018')))

SELECT  
    @END_DT = CONVERT(VARCHAR, DATEPART(MM, DATEADD(DAY, -75, '4/10/2018'))) + '/20/' + CONVERT(VARCHAR, DATEPART(YEAR, DATEADD(DAY, -75, '4/10/2018')))

SELECT  
    @START_DT, @END_DT
728x90

1 Answers SQL dates returns 12/20/18 when it should be 12/20/17

You need to go further back in time to get to 2017. Try subtracting 100 instead of 75.

DECLARE @TODAYS_DT DATE = '4/10/2018'

DECLARE @START_DT CHAR(10)
DECLARE @END_DT   CHAR(10)

SELECT  
    @START_DT = CONVERT(VARCHAR, DATEPART(MM, DATEADD(MM, -1, DATEADD(DAY, -100, '4/10/2018')))) + '/21/' + CONVERT(VARCHAR, DATEPART(YEAR, DATEADD(DAY, -100, '4/10/2018')))

SELECT  
    @END_DT = CONVERT(VARCHAR, DATEPART(MM, DATEADD(DAY, -100, '4/10/2018'))) + '/20/' + CONVERT(VARCHAR, DATEPART(YEAR, DATEADD(DAY, -100, '4/10/2018')))

SELECT  
    @START_DT, @END_DT

11 months ago