I am having trouble determining the best way to compare dates in SQL based on month and year only.
We do calculations based on dates and since billing occurs on a monthl
You can use formatting your date like this 'yyyyMM' , so only the month in the same year will be selected.
SELECT *
FROM tableName
WHERE FORMAT(date_month_bill, 'yyyyMM') < FORMAT(DATEADD(MONTH, -1, GETDATE()), 'yyyyMM')
AND FORMAT(date_month_bill, 'yyyyMM') > FORMAT(DATEADD(MONTH, -3, GETDATE()), 'yyyyMM')