I current run the below script to get the current day minus 1 and the current month. It works great for all days and month except for the 8th of every month and August of every year. I have to change the script to setting it manually for August. Does anyone know why and is there a fix.
SET m=%date:~4,2%
SET /A m -= 1
SET m=0%m%
REM ****** SET m=08 this was used because the date was not right ******
REM SET m=08
SET currMon=%date:~4,2%/%date:~10,4%
REM ****** SET PriorMon=12/2017 this was used for Year End because the date was not right ******
REM SET PriorMon=08/2018
SET PriorMon=%m:~-2%/%date:~10,4%
0are interpreted as octal numbers.08and09are invalid values in octal system. For that reason these two invalid values are replaced by0on evaluation of the arithmetic expression. There are really dozens of answers showing how to work around unexpected interpretation of a value with a leading0as octal number. And there are really dozens of date maths related answers on Stack Overflow, too. It is always a good idea to first research before starting a development and re-invent something which others have already coded perfect and published.