设置昨天的批处理文件 [英] Set Yesterday BATCH FILE

查看:46
本文介绍了设置昨天的批处理文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果这给了我今天的约会日期...

If this gives me today's date...

SET TODAY=%date:~7,2%.%date:~-10,2%.%date:~-4,4%

...如何获取昨天的日期?我可以用相同的样式吗?

...how can i get yesterday's date? Can I get it in the same style?

感谢您的帮助!

推荐答案

更改最后三行中三个变量的顺序以适合您:

Change the order of the three variables in the 3rd last line to suit you:

:: yesterdays date
@echo off
set day=-1
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%day%,now) : d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^& right(100+month(s),2)^& right(100+day(s),2)
for /f %%a in ('cscript /nologo "%temp%\%~n0.vbs"') do set "result=%%a"
del "%temp%\%~n0.vbs"
set "YYYY=%result:~0,4%"
set "MM=%result:~4,2%"
set "DD=%result:~6,2%"
set "date-yesterday=%yyyy%-%mm%-%dd%"

echo Yesterday was "%date-yesterday%"
pause

这篇关于设置昨天的批处理文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆