I have this code in which I want to obtain the subtraction of a day from the current date, from 0 to -10, but I only correctly obtain the last one that is out of the cycle, any idea why?
echo off
Setlocal EnableDelayedExpansion
FOR /L %%A IN (0,1,10) DO (
FOR /F "usebackq tokens=*" %%t IN (`powershell -NoProfile -Command "(Get-Date).AddDays(-%%A).ToString('yyyy/MM/dd HH:MM:ss')"`) DO (SET "START_DATE=%%t")
echo START_DATE: %START_DATE%
)
echo START_DATE: %START_DATE%
Endlocal
pause
PopD
exit
and what I get in the terminal is this
echo off
START_DATE:
START_DATE:
START_DATE:
START_DATE:
START_DATE:
START_DATE:
START_DATE:
START_DATE:
START_DATE:
START_DATE:
START_DATE:
START_DATE: 2020/07/22 11:07:06
Presione una tecla para continuar . . .