Having issues with value of 08 Using SET /a in a windows batch file

Solution 1:

Octal uses only 0-7, 8 and 9 are not numbers in it. 08 is an octal literal, but an invalid one (8 in octal is 011), thus the error. Drop the leading 0.

It gets these values from your locale settings, so I know "drop the 0" is kinda useless advice. The reason it's working without the /a is because of the data type I'd say (and type conversion):

set [<variable>=[<string>]]
set /a <variable>=<expression>

In the first syntax, the variable is set to a string, in your case '08', which is converted to a number (implicitly, because date expects a number) by dropping the leading 0 (or 0s), so it's being interpreted as the number 8.

When 08 is an expression instead, as in the 2nd syntax, it is interpreted as a numeric literal first, in this case octal, and 08 is invalid.

Solution 2:

You can solve it with some math.

set /a month=1%date:~4,2% - 100

This prefix the number with a 1, all two digit month will become a valid number over one hundred.
Then it's only necessary to subtract 100.

08 -> 180
12 -> 112