Thanks in advance for any suggestions
Norm
Ritchie previously posted an extremely nice DATEMATH batch file, which
you could use to do this *if* you have Win2000 or WinXP.
<Win2000> c:\cmd>demo\DoFromTo 20021001 20021009
java YourClass 20021001
java YourClass 20021002
java YourClass 20021003
java YourClass 20021004
java YourClass 20021005
java YourClass 20021006
java YourClass 20021007
java YourClass 20021008
java YourClass 20021009
=====begin c:\cmd\demo\DoFromTo.cmd====================
1. @echo off
2. set date_parm=%1
3. set stop_date=%2
4. :next_day
5. echo java YourClass %date_parm%
6. call DATEMATH %date_parm% +1
7. set date_parm=%DATEMATH%
8. if %date_parm% GTR %stop_date% goto :EOF
9. goto :next_day
=====end c:\cmd\demo\DoFromTo.cmd====================
Here's a slightly modified version of Ritchie's DATEMATH batch
file, along with a general-purpose XHELP file:
=====begin C:\CMD\TEST\datemath.cmd====================
01. @echo off&setlocal&set cd=
02. ::
03. :: Syntax: [ yyyymmdd OR today ] [+ OR -]nnnnn [.]
04. ::
05. :: where 'nnnnn' is the number of days to add or subtract
06. ::
07. :: Examples: %~n0 20010501 +234 .
08. :: %~n0 today -12345
09. ::
10. :: Note that there is NO SPACE between the plus or minus sign and the
11. :: number of days.
12. ::
13. :: The result is returned in environment variable %~n0 in yyyymmdd format.
14. ::
15. :: A third (optional) argument of '.' will display the result on screen.
16. ::
17. if [%1] NEQ [] if [%1] NEQ [?] if [%1] NEQ [/?] if [%1] NEQ [-?] if /i [%1] NEQ [HELP] goto :begin
18. call XHELP %~f0
19. goto :EOF
20.
21. :begin
22. if not defined cd (echo.&echo Win2000 or WinXP only.&goto :EOF)
23. set mydate=%1
24. if /i "%mydate%" NEQ "TODAY" goto :YMD
25.
26. set mydate=%date:~4%
27. set mydate=%mydate:/=%
28. set mydate=%mydate:~4,4%%mydate:~0,4%
29.
30. :YMD
31.
32. set M=%mydate:~4,2%
33. set D=%mydate:~6,2%
34. set Y=%mydate:~0,4%
35. set TD=%D%X
36. set TM=%M%X
37. if %TD:~1,1%==X ( set D=10%D% ) else ( set D=1%D% )
38. if %TM:~1,1%==X ( set M=10%M% ) else ( set M=1%M% )
39. set /a D-=100,M-=100
40.
41. set operation=%2
42.
43. :: Generate a Magic number from %D% %M% %Y%
44. set /a X=(1461*(Y+4800+(M-14)/12))/4+(367*(M-2-12*^
45. ((M-14)/12)))/12-(3*((Y+4900+(M-14)/12)/100))/4+D-32075
46.
47. :: Do date arithmetic here, eg 'set /a X+=30'
48.
49. set /a X = X %operation%
50.
51. :: Convert Magic number back to a date
52. set /a L=X+68569
53. set /a N=(4*L)/146097
54. set /a L=L-(146097*N+3)/4
55. set /a K=(4000*(L+1))/1461001
56. set /a L=L-(1461*K)/4+31
57. set /a J=(80*L)/2447
58. set /a D=L-(2447*J)/80
59. set /a L=J/11
60. set /a M=J+2-(12*L)
61. set /a Y=100*(N-49)+K+L
62.
63. set /a D+=100,M+=100
64.
65. if [%3]==[.] echo %Y% %M:~1% %D:~1%
66. endlocal&set %~n0=%Y%%M:~1%%D:~1%&goto :EOF
=====end C:\CMD\TEST\datemath.cmd====================
=====begin C:\CMD\TEST\xhelp.cmd====================
01. @echo off
02. ::
03. :: Displays the contents of the 'flowerbox' in a CMD or BAT
04. :: file.
05. ::
06. :: '%~n0' will be displayed as the name of the referenced file
07. ::
08. echo .?./?.-?.help.. | findstr /i ".%1." > nul
09. if %errorlevel% EQU 0 (
10. call XHELP %~f0
11. goto :EOF
12. )
13. setlocal
14. set cd=
15. set whichfile=%1
16. for /f "tokens=*" %%a in (
17. 'dir %whichfile% ^| find "/"'
18. ) do set direntry=%%a
19. set fname=%~n1
20. echo :
21. echo : %direntry:~0,38% %whichfile%
22. echo :
23. for /f "tokens=* delims=" %%* in (
24. 'findstr /b /c:"::" %whichfile%') do call :display %%*
25. endlocal& goto :EOF
26. :display
27. set line=%*
28. set line=%line:~1%
29. if not defined cd set line=%line:~1%
30. call set line=%%line:^%~n0=%fname%%%
31. echo %line%
32. goto :EOF
33. :EOF
34.
=====end C:\CMD\TEST\xhelp.cmd====================
If you are using WinNT 4.0, please say so and I will post a CALCDATE
batch file that will do date calculations. Alternatively, you could
use WSH to do date calculations. What's your preference?
--
U s e ' R e p l y - T o ' a d d r e s s o r
u n z i p ' F r o m ' t o s e n d m a i l
Hello Phil,
That must have been the first datemath function I ever wrote (and before I
knew about NT's nuances). All the date and time functions I've written
since support NT4... in fact they're all online..........
http://www.commandline.co.uk/cmdfuncs/index.html
--
Ritchie
Undo address for mail
Thanks, Ritchie! A truly stellar collection!