[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖
本帖最后由 flyinnet9 于 2015-8-12 09:54 编辑

改了以前写的程序,想前几天应该都可以(28天??),测试后结果说一下
闰年判断有误,已改正
  1. @echo off
  2. setlocal enabledelayedexpansion
  3. set daysago=7
  4. set year=%date:~0,4%
  5. set month=%date:~5,2%
  6. set day=%date:~8,2%
  7. if %day% gtr %daysago% goto normal
  8. if %month%==03 goto february
  9. if %month%==01 goto aty
  10. for %%i in (05 07 10 12) do if %month%==%%i goto abortion
  11. for %%i in (02 04 06 08 09 11 ) do if %month%==%%i goto monthly
  12. :abortion
  13. set /a day=30+!day!
  14. if %month:~0,1%==0 set /a month=%month:~1%
  15. set /a month=!month!-1
  16. if !month! lss 10 set month=0!month!
  17. goto normal
  18. :monthly
  19. set /a day=31+!day!
  20. if %month:~0,1%==0 set /a month=%month:~1%
  21. set /a month=!month!-1
  22. if !month! lss 10 set month=0!month!
  23. goto normal
  24. :february
  25. set month=02
  26. if %year:~2,4%==00 (set /a yy=%year%%%400) else (set /a yy=%year%%%4)
  27. if %yy%==0 (set /a day=29+!day!) else (set /a day=28+!day!)
  28. goto normal
  29. :aty
  30. set /a day=31+!day!
  31. set month=12
  32. set /a year=%year%-1
  33. goto normal
  34. :normal
  35. set /a Yourday=!year!!month!!day!-%daysago%
  36. echo Today is %date:~0,4%%date:~5,2%%date:~8,2%
  37. echo Yourday is %Yourday%
  38. pause
复制代码

TOP

返回列表