Batch File 'Time Since'

May 9, 2009 at 03:37:34
Specs: Windows Vista
i've finally got my batch working, and now i'm just smoothing things out.
is there a way to automatically calculate the the number of days since a certain date??

See More: Batch File Time Since

Report •

May 11, 2009 at 15:39:50
This Help

@echo off
if (%6)==() goto Syntax
echo Date1=%1/%2/%3
call :CalcDateNo %1 %2 %3
set Date1=%Z%
echo Date1 No=%Z%
call :CalcDateNo: %4 %5 %6
echo Date2=%4/%5/%6
set /a Diff=%Z%-%Date1%
echo Date2 No=%Z%
echo Diff=%Diff%
exit /b

:CalcDateNo %1 %2 %3
set Day=%1
set Month=%2
set Year=%3

rem Delele Leading Zeros
set Char=%Day:~0,1%
if %Char%==0 set Day=%Day:~1,1%
set Char=%Month:~0,1%
if %Char%==0 set Month=%Month:~1,1%
if %Month% LEQ 2 (
set /a Year-=1
set /a Month+=12
set /a Month+=1
set /a A=%Year%/100
set /a B=2-%A%+%A%/4
set /a C=36525*%Year%/100
set /a D=306001*%Month%/10000
set /a E=%Day%+1720995+%B%
set /a Z=%C%+%D%+%E%
exit /b

echo Enter DateCalc Day Month Year Day Month Year
echo ie DateCalc 05 08 2009 05 08 2010
echo Calculate Difference between
echo Date1 and Date2
echo One leading zero is accepted
echo for Day and Month, Year must be
echo be in full. Date not validated.
exit /b

Report •
Related Solutions

Ask Question