| Junior Member with 7 posts. THREAD STARTER | | Join Date: Dec 2011 Experience: Intermediate | |
Automatically include the previous date in a batch file? Hi,
I added below script in my batch file but the date part gives wrong info,but both year & month giving correct...please help me to solve this problem...
echo wscript.echo ^(Date^(^)- 1^)>yesterday.vbs
for /f %%a in ('cscript //nologo yesterday.vbs') do set ydate1=%%a
del yesterday.vbs
set ydate1=%ydate1:/=%
set m=%ydate1:~0,2%
set d=%ydate1:~2,2%
set y=%ydate1:~-2,2%
set ydate2=%y%%m%%d%
echo yesterday was %ydate2%
pause
Here are the output which i got...
D:\mujeeb\software>set ydate1=12/1/2011
D:\mujeeb\software>del yesterday.vbs
D:\mujeeb\software>set ydate1=1212011
D:\mujeeb\software>set m=12 D:\mujeeb\software>set d=12
D:\mujeeb\software>set y=11
D:\mujeeb\software>set ydate2=111212
D:\mujeeb\software>echo yesterday was 111212
yesterday was 111212
D:\mujeeb\software>pause
Press any key to continue . . .
Here the date should have been shown 01 instead of 12...
Thanks In Advance... |