Here is one more convoluted batch way to get the date minus a number of days. This uses a trick with XCOPY to validate that the date is valid.
@echo off
setlocal
set rand=%random%
md "dummy%rand%\empty%rand%"
for /f "tokens=2 delims==" %%a in ('wmic OS Get localdatetime /value') do set "dt=%%a"
set /a y=%dt:~0,4%
set /a m=1%dt:~4,2%
set /a d=1%dt:~6,2%
REM set the number of days to substract
SET DAYS=4
FOR /L %%G IN (1,1,%days%) DO CALL :loop
set subdate=%y%%m:~-2%%d:~-2%
echo %subdate%
rd /s /q "dummy%rand%"
pause
endlocal
GOTO :EOF
:loop
set /a d-=1
if %d% lss 101 (
set d=131
set /a m-=1
if %m% lss 101 (
set m=112
set /a y-=1
)
)
xcopy /d:%m:~-2%-%d:~-2%-%y% /t "dummy%rand%\empty%rand%" "dummy%rand%" >nul 2>&1 || goto loop
GOTO :EOF