All you need to do is deduct the additional month if the end date has not yet passed the day of the month in the start date.
DECLARE @StartDate AS DATE = '2019-07-17'
DECLARE @EndDate AS DATE = '2019-09-15'
DECLARE @MonthDiff AS INT = DATEDIFF(MONTH,@StartDate,@EndDate)
SELECT @MonthDiff -
CASE
WHEN FORMAT(@StartDate,'dd') > FORMAT(@EndDate,'dd') THEN 1
ELSE 0
END