By changing the number in this variable day=+1
to will add more days to your result, or changing to day=-1
will remove a day etc..
@echo off
set day=+1
echo>"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YYYY=%result:~0,4%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "result=%yyyy%-%mm%-%dd%"
echo %DD%
pause
This will only echo the day +1. If however you want to echo the full date result, simply do echo %result%
YYYY
, MM
and DD
have been split into single variables anyway so you can use it if you like.
Just as a sidenote:
echo>"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right
is pretty much the same as:
echo s=DateAdd("d",%day%,now) : d=weekday(s) >"%temp%\%~n0.vbs"
echo WScript.Echo year(s)^& right(100+month(s),2)^& right >>"%temp%\%~n0.vbs"
CMD
will pretty much do the same for both and that is to pipe the output to file. I simply do this so by reading the line, you can immediately see what the line does, echo
ing to external file, the string that follows.