1, the use of set/a to remove the date before the number 0, such as: 2007-09-25 in the month of 09 before the 0 (of course, this month is unknown, simple to say
Yes no matter whether there are 0 to be guaranteed to remove the front:
Demo Code:
Copy Code code as follows:
@echo off
Set day=1%date:~5,2%
set/a day-=100
Echo%day%
Pause>nul
In addition, you can (in depth use, more advantages than the previous one):
Copy Code code as follows:
@echo off
set/a day1=%date:~5,1%,day2=%date:~6,1%
set/a day=%day1%*10+%day2%
Echo%day%
Pause>nul
2, the use of set/a (numerical operation division in the divisor does not allow 0) return value to set the numerical operation of the carry flag;
Demo Code:
@echo off 2>nul 3>nul
set/a num1=7,num2=2
set/a var=%num1%+%num2%
SET/A 1/(%VAR%/10) && echo greater than 10 | | Echo is less than 10
Pause>nul
Plus a large number of addition operations demo code: (first complement)
Copy Code code as follows:
@echo off&setlocal enabledelayedexpansion
Set num1= 984322212445613542523552165432136516565135132354123432987619431469731611346143789
Set num2= 657973265856194306419643120641631361303163006131061301613061130161300613061130
Call:lineup num1
Call: Lineup num2
set/a flag=0
for/l%%i in (1 1 199) do (
set/a var=!num1:~-%%i,1!+!num2:~-%%i,1!+!flag!
Set var=0!var!
Set flag=!var:~-2,1!
Set str=!var:~-1!! Str!
)
for/f "Delims=0 tokens=*"%%i in ("!str!") doing echo%%i
Pause>nul
: Lineup obj
for/ L%%i in (1 1) do set%1=0!%1!
Call Set%1=!%1:~-200!