这个是计算日期的,其他的你自己摸索一下吧!- @echo off & setlocal enabledelayedexpansion &rem by author Gan
-
- set /p "time_end=请输入停止日期(格式:2020/01/01):"
- set /p "time_go=请输入起始日期(格式:20200101):"
- del /q old_date.txt 1>nul 2>nul
-
- >old_date.txt (for /l %%a in (1,1,999) do (
- set /a nd=%%a
- call :runnian %time_end:~0,4%
- call :test
- if !m! lss 10 set m=0!m!
- if !d! lss 10 set d=0!d!
- echo !y!!m!!d!
- if !y!!m!!d! equ %time_go% goto :pa
- ))
- :pa
- pause & eixt
- ::exit /b 0
- :test
- for /f "tokens=1-3 delims=/ " %%a in ("%time_end%") do (set /a y=%%a, m=1%%b%%100, d=1%%c%%100)
- if !nd! lss %d% (set /a d-=nd & goto :eof)
- set /a d_m=m-1, exd=0
- for /l %%a in (1,1,!d_m!) do (set /a exd+=m%%a)
- set /a exd+=d
- if !nd! GEQ %exd% (set /a nd-=exd, m=12, y-=1
- call :runnian !y! ) else (set /a nd-=d, m-=1)
- :loop
-
- if !nd! GTR !count! (set /a nd-=!count!, m=12, y-=1& call :runnian !y!& goto :loop)
- for /l %%a in (1,1,2) do (
- if !m! LEQ 0 (set /a m=12, y-=1 & call :runnian !y!)
- set /a md = m!m!
- if !nd! lss !md! (set /a d=md-nd & goto :eof)
- set /a nd-=md, m-=1
- goto :loop)
-
- :runnian
- set /a m1=31, m2=28, m3=31, m4=30, m5=31, m6=30, m7=31, m8=31, m9=30, m10=31, m11=30, m12=31
- set /a n=0
- set /a a=%1%%4,a1=%1%%100,a2=%1%%400
- if !a! equ 0 set n=1& if !a1! equ 0 set n=0
- if !a2! equ 0 set n=1
- if !n! equ 1 (set /a m2=29, count=366) else (set /a m2=28, count=365)
- goto :eof
复制代码
|