I am using the date command for a batch script.
I am wondering how to use command date to get yesterday date.
标签:
batch-file
相关问题
- xcopy include folder
- Batch file if string starts by
- Jenkins - cmd is not recognized
- String Manipulation with case sensitivity
- Writing an EXE output to a batch file
相关文章
- Extracting columns from text file using Perl one-l
- How can one batch file get the exit code of anothe
- How to make jenkins fail at a failing windows batc
- Problems using start-process to call other powersh
- Python utilizing multiple processors
- Why do all Pre-build or Post-build events in Visua
- Windows batch file - how to loop through files in
- Set variable in “if” block
The EASIEST way to get yesterdays date (YYYYMMDD) in batch is the following:
Simply create a batch file and add this:
i accomplished yesterdays date as follows.
the format can be changed in line 3
sample output: 03-13-2013
this is the simplest way i found to do this.
Anytime you hear batch, think Rob Van der Woude. Anyway, here's yesterday.bat.
1) Here's a script called
yesterday.bat
:you can use it like
2) Here's a one-liner with powershell which you most probably have installed:
and you can assign this to variable:
Looking at @JRL's answer... If it's truly that hard, perhaps use PowerShell and then do similar to Powershell's Get-date: How to get Yesterday at 22:00 in a variable?
You can call to PowerShell in a bat file like so: Use bat to start Powershell script
You'll end up with a three or four liner solution rather than the 100 or so written (immaculately I'll add) by Rob Van der Woude.
Good luck...