The correct method for establishing the numeric day of the week has been given by multiple contributors "$(date +%u)" but the OP's original logic was flawed. The modulus 7 of the day of the month is not the day of the week!