本帖最后由 happy886rr 于 2016-6-22 11:12 编辑
回复 1# GNU
请在命令行下使用,类似第三方用法。
示例:- i.cmd 201510 201603
- REM 显示结果:
- 201511
- 201512
- 201601
- 201602
复制代码 i.cmd代码:- @echo off&setlocal enabledelayedexpansion
- set A=%1&set B=%2
- if "%1"=="" (echo;用法示例:&set/p=%~nx0 [开始年月] [结束年月]&exit)
- set/a y=!B:~0,4!-!A:~0,4!+1
- set/a m=1!B:~-2!-1!A:~-2!-1
- if !m! lss 0 (set/a "m+=12,y-=1")
- for /l %%i in (0 1 !y!) do (
- if %%i gtr 0 (if %%i lss !y! (set/a CYC=12) else (set/a CYC=m))
- for /l %%j in (1 1 !CYC!) do (
- set/a mm=%%j+1!A:~-2!
- set/a yy=%%i+!A:~0,4!-1
- if !mm! gtr 112 (set/a "mm-=12,yy+=1")
- echo !yy!!mm:~-2!
- )
- )
复制代码
|