# Solved MS DOS - How to get the day difference betwee

July 12, 2011 at 06:45:30
Specs: Windows 7
 MS DOS - How to get the day difference between two dates?

See More: MS DOS - How to get the day difference betwee

#1
July 12, 2011 at 21:14:18
 Test this. It is assumed that the second date will always be greater than the first, if not then you should code a routine to check this and branch to a suitable routine.```@echo off cls setlocal set mm=7 set dd=14 set year=2011 call :convjdate set juldate=%jdate% set mm=7 set dd=20 set year=2011 call :convjdate set juldate1=%jdate% set /a daydiff=%juldate1%-%juldate% echo Difference=%daydiff% days. exit /b :convjdate :: Convert Gregorian date to Julian date :: Algorithm based on Fliegel-Van Flandern :: algorithm from the Astronomical Almanac, :: provided by Doctor Fenton on the Math Forum :: (http://mathforum.org/library/drmath/view/51907.html), :: and converted to batch code by Ron Bakowski. SET /A Month1 = ( %MM% - 14 ) / 12 SET /A Year1 = %year% + 4800 SET /A jdate = 1461 * ( %Year1% + %Month1% ) / 4 + 367 * ^ ( %MM% - 2 -12 * %Month1% ) / 12 - ( 3 * ( ( %Year1% + %Month1% + 100 ) / ^ 100 ) ) / 4 + ^%DD% - 32075 ```Please come back & tell us if your problem is resolved.

Report •

#2
July 13, 2011 at 07:22:57
 It worked. Thanks.

Report •

#3
July 13, 2011 at 16:22:11
 One caret too many. The caret (^) on the final line, just before %DD% is not required. It does no harm to the execution of the script but can be removed. Sorry about that.Thanks for coming back to report your success.W.Please come back & tell us if your problem is resolved.

Report •

Related Solutions