If I'm not mistaken, your expression (reorganized here a bit), finds the week number corresponding to the first day of the current month, the week number corresponding to today, and calculates the difference as week-of-month?
first=$(date -d "-$(($(date +%d)-1)) days")
weekofmon=$(( 1 + $(date +%V) - $(date -d "$first" +%V) ))
If that's right, and you want the week-of-month for last week, shouldn't it be enough to just replace "today" with "7 days ago" (in all places) to get the month-of-week corresponding to that date?
now="7 days ago"
first=$(date -d "$now - $(($(date +%d -d "$now" )-1)) days")
weekofmon=$(( 1 + 10#$(date +%V -d "$now") - 10#$(date -d "$first" +%V) ))
The relies on
date being able to parse expressions like "7 days ago - 3 days".
date +%V prints week numbers < 10 with a leading zero, which would cause them to be interpreted as octal numbers, breaking
09. Add the
10# to force bash to take the numbers in decimal.
A bit shorter way to get the first day of the same month:
first=$(date -d "$now" +"%Y-%m-01")
(different format, but
date should be able to interpret it.)