On Wed, 28 Nov 2007 09:50:18 -0500, "ajmister" <(E-Mail Removed)> wrote:
> Here is my add date script.
>
>echo off
>for /F "tokens=1,2,3" %%r in ('date /t') do (
>for /f "tokens=1,2,3 delims=/" %%c in ("%%s") do set filedte=%%e%%c%%d
>)
>echo %filedte%
>
>ren coverage.txt coverage.txt_%filedte%
>
>If the script runs after midnight I need my script to pick previous day's
>date instead of current day's date. My script runs anytime between 10 pm and
>6 am the next day.
To figure out which day it is use the time and see if it is before 10, and run
an appropriate routine.
Use %day% which will be populated with the result EG: 2007-11-28
@echo off
for /f "delims=:" %%a in ("%time%") do if %%a LSS 10 (
set qty=-1
call :getdate
) else (
set qty=0
call :getdate
)
echo %%day%% is set to "%day%"
goto :EOF
:getdate
set date1=now
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%qty%,%date1%)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^&_
echo>>"%temp%\%~n0.vbs" right(100+month(s),2)^&_
echo>>"%temp%\%~n0.vbs" right(100+day(s),2)
for /f %%a in (
'cscript //nologo "%temp%\%~n0.vbs"') do set result=%%a
del "%temp%\%~n0.vbs"
set day=%result:~0,4%-%result:~4,2%-%result:~6,2%
If you are unable to use WSH then here is a thread that could help you:
http://groups.google.com.au/group/al...883858bfaf0fa5