S
S
sflyer2017-09-14 11:20:54
cmd/bat
sflyer, 2017-09-14 11:20:54

Bat script - subtracting a month, what am I doing wrong?

set dd=%DATE:~0,2%
set mm=%DATE:~3,2%
set yyyy=%DATE:~6,4%
echo %mm%
IF %mm:~0,1% EQU 0(SET mm=%mm:~1,1% )
set /a mm=%mm%-1
 echo %mm%
pause

Conclusion 15ad49d559c14b4c89b6d5d31a0322eb.png
As you can see in the output - set puts the value 9 instead of 09, but then 09 comes again in the mm variable, what should I change to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sflyer, 2017-09-14
@sflyer

The code is working, the problem was in the script file itself.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question