Thats what I needed! Thanks to both of you.
I have one autoindex to set the value and another to remove it.
Tested and working.
SELECT
DWDOCID
FROM BOOKINGDEALS
WHERE DATEPART(m, ContractDate) = DATEPART(m, CAST(GETDATE()AS Date)) -1
AND DATEPART(yyyy, ContractDate) = DATEPART(yyyy, (DATEADD(m, -1, GETDATE())))
;
SELECT
DWDOCID
FROM BOOKINGDEALS
WHERE DATEPART(m, ContractDate) = DATEPART(m, CAST(GETDATE()AS Date)) -2
AND DATEPART(yyyy, ContractDate) = DATEPART(yyyy, (DATEADD(m, -2, GETDATE())))
AND Status = 'PREVIOUSMONTH'