- Rem 取2天之前的日期,取回放入变量olddate
- echo wscript.echo dateadd("d",-2,date) >tmp.vbs
- for /f "tokens=1,2,3* delims=-" %%i in ('cscript /nologo tmp.vbs') do set y=%%i
- echo %y% >tmp.txt
- for /f "delims=/ tokens=1" %%i in (tmp.txt) do set "y=%%i"
- for /f "delims=/ tokens=2" %%i in (tmp.txt) do set "m=%%i"
- for /f "delims=/ tokens=3" %%i in (tmp.txt) do set "d=%%i"
- echo %y%>> tmp.txt
- echo %m%>> tmp.txt
- echo %d%>> tmp.txt
- if %m% LSS 10 set "m=0%m%"
- if %d% LSS 10 set "d=0%d%"
- pause
- set "nowdate=%date:~0,4%%date:~5,2%%date:~8,2%"
- set "olddate=%y%%m%%d%"
- pause
- del tmp.txt /q /f
- del tmp.vbs /q /f
- echo 今天的日期:%nowdate%
- echo 2天前的日期:%olddate%
- pause
复制代码