using YESTERDAYs date in bat

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
 
J

Jerold Schulman

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
 
T

Torgeir Bakken \(MVP\)

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%
 
J

Jerold Schulman

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
 
A

Alexander Suhovey

Jerold,
I was under impression that this idea is already somewhere in your
Tips&Tricks.

Al.
 
A

Alexander Suhovey

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.
 
J

Jerold Schulman

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top