I don't think this is pretty but it works
declare @date datetime
declare @prodid nvarchar(20)
declare @m nvarchar(2)
declare @y nvarchar(4)
set @prodid = 'prod1'
set @y = 2009
set @m = 3
set @date = cast(@m + '/1/'+ @y as datetime)
select prodid, sum(payment)
from (
select *, cast(month + '/1/'+ year as datetime) as date
from #temp1
) as temp2
where date between dateadd(mm,-12,@date) and dateadd(mm,-1,@date)
and prodid = @prodid
group by prodid