using YESTERDAYs date in bat

  • Thread starter Thread starter Henry
  • Start date Start date
H

Henry

Hi all

Amazing to see how often people have trouble with the
date. Here I am today STUCK with the date...

I have a bat that runs every day. I now need to do a few
things making use of yesterdays date. I have no problem
with the current date I just don't know how the get
yesterdays date. The problem arises on the 1st of every
month.

Does anyone know how I figure out what was yesterdays
date? Or is there some utility out there with which I can
achieve this?

Thanks
 
Hi all

Amazing to see how often people have trouble with the
date. Here I am today STUCK with the date...

I have a bat that runs every day. I now need to do a few
things making use of yesterdays date. I have no problem
with the current date I just don't know how the get
yesterdays date. The problem arises on the 1st of every
month.

Does anyone know how I figure out what was yesterdays
date? Or is there some utility out there with which I can
achieve this?

Thanks

See tip 8252 in the 'Tips & Tricks' at http://www.jsiinc.com

Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Henry said:
Amazing to see how often people have trouble with the
date. Here I am today STUCK with the date...

I have a bat that runs every day. I now need to do a few
things making use of yesterdays date. I have no problem
with the current date I just don't know how the get
yesterdays date. The problem arises on the 1st of every
month.

Does anyone know how I figure out what was yesterdays
date? Or is there some utility out there with which I can
achieve this?
Hi

This is one way of doing it:

@echo off
echo WScript.Echo DateAdd("d", -1, Date) >%temp%\yesterday.vbs
for /f "tokens=*" %%a in (
'cscript.exe //Nologo %temp%\yesterday.vbs') do set yesterday=%%a
del %temp%\yesterday.vbs
echo Yesterdays date: %yesterday%
 
Hi

This is one way of doing it:

@echo off
echo WScript.Echo DateAdd("d", -1, Date) >%temp%\yesterday.vbs
for /f "tokens=*" %%a in (
'cscript.exe //Nologo %temp%\yesterday.vbs') do set yesterday=%%a
del %temp%\yesterday.vbs
echo Yesterdays date: %yesterday%

Great. I am going to 'borrow' this.


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Jerold,
I was under impression that this idea is already somewhere in your
Tips&Tricks.

Al.
 
Well, I'm not saying it *is* there :), I just though it *should* be there
for ages since it is a common way to do date/time maths in batch scripts.

Then again, looking through T&T it is obvious that Jerold can do virtually
everything with pure batch :)

Al.
 
You might be thinking of tip 8252 in the 'Tips & Tricks' at
http://www.jsiinc.com



Well, I'm not saying it *is* there :), I just though it *should* be there
for ages since it is a common way to do date/time maths in batch scripts.

Then again, looking through T&T it is obvious that Jerold can do virtually
everything with pure batch :)

Al.


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 
Back
Top