I have to execute a program.exe that generate me reports for a range of dates, I call the program.exe in a command line but i have to set two argument (current date and current_date-6days) when I call it :
c:\program.exe current_date current_date-6 (date before 6 days)
i found that this command gives me the current date : 28-06-2013
%date:~0,2%-%date:~-7,2%-%date:~-4,4%
but I can't get the current_date-6 (means the date 6 days before)
i have also to let the user choose the range of date he want ...
how I can proceed to execute the program 1 )automatically (windows schedular) by giving him the two parametres (current date , and date of 6 days before for example) 2) and manually in the same time, by giving the users the possibility of choosing a range of dates
@echo off
set /a currd=%date:~0,2%
set /a currm=%date:~3,2%
set /a curry=%date:~6,4%
set /a d=%date:~0,2%
set /a m=%date:~3,2%
set /a y=%date:~6,4%
FOR %%A IN (1 2 3 4 5 6) DO (
:loop
set /a d-=1
if %d% LSS 1 (
set d=1
set /a m-=1
if %m% LSS 1 (
set m=12
set /a y-=1
)
)
xcopy /d:%m%-%d%-%y% /l . .. >nul 2>&1 || goto loop
)
start /WAIT /B "" "C:\MyPGM.exe" "%d%-%m%-%y%" "%currd%-%currm%-%curry%"
for the 28/06/2013 I have no problem but for the 01/07/2013 it generate me an error "String was not recognized as a valid DateTime"