回复 1# ethan.huang - @echo off
- set "DateA=2022-08-17"
- set "DateB=2022-08-05"
- call :DateToDays %DateA:~0,4% %DateA:~5,2% %DateA:~8,2% DaysX
- call :DateToDays %DateB:~0,4% %DateB:~5,2% %DateB:~8,2% DaysY
- set /a DayZ=DaysX-DaysY
- echo %DateA%和%DateB%间隔的天数是:%DayZ%
- pause
- goto :eof
-
- :DateToDays %yy% %mm% %dd% days
- setlocal ENABLEEXTENSIONS
- set yy=%1&set mm=%2&set dd=%3
- if 1%yy% LSS 200 if 1%yy% LSS 170 (set yy=20%yy%) else (set yy=19%yy%)
- set /a dd=100%dd%%%100,mm=100%mm%%%100
- set /a z=14-mm,z/=12,y=yy+4800-z,m=mm+12*z-3,j=153*m+2
- set /a j=j/5+dd+y*365+y/4-y/100+y/400-2472633
- endlocal&set %4=%j%&goto :EOF
复制代码
|