If you want dd to be 2 digits, you can also add "if %dd% lss 10 set dd=0%dd%"
rem Check the first digit of dd, if it is 0, then set dd to only the 2nd digit
if {%dd:~,1%}=={0} set dd=%dd:~1%
rem Convert dd to a number and subtract 1
set /a dd-=1
rem If dd is only 1 digit, pad with a 0
if %dd% lss 10 set dd=0%dd%
Main Topics
Browse All Topics





by: GuruGaryPosted on 2006-03-08 at 15:49:29ID: 16140113
If I understand correctly, you want want to fix the dd value if it is less than 10. Try something like this:
rem Check the first digit of dd, if it is 0, then set dd to only the 2nd digit
if {%dd:~,1%}=={0} set dd=%dd:~1%
rem Convert dd to a numerical value
set /a dd=%dd%
rem Subtract 1 from dd
set /a dd-=1