How to update absolute cell number

I have the following formula in a cell

=(E2-(SUMPRODUCT(WEEKDAY(G2:G$31)=1)+SUMPRODUCT(WEEKDAY(G2:G$31)=5)))

Now, depending on a month G$31 will change, that is the last two digits will change. How to add an integer to
the cell address?
to get from G$31 --> G$29 for example. I tried substructionG$(31 -2) but it did not work.

OFFSET(G$31;-2;0)

So probably

=(E2-(SUMPRODUCT(WEEKDAY(G2:OFFSET(G$31;-2;0))=1)+SUMPRODUCT(WEEKDAY(G2:OFFSET(G$31;-2;0))=5)))

if I understood correctly.

@erAck, yes this works! Thank you. I can’t upvote, don’t have yet 5 points.

Marking the answer as correct with the check mark is fine, thanks!