Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Yesterday in wscript 1

Status
Not open for further replies.

kwj1027

IS-IT--Management
Aug 10, 2004
28
0
0
US
Greetings,

I am attempting to determine yesterday's date with the code below. %YDAY% is coming back as 6, today is the 8th so I am expecting 7. I am going buggy trying to figure this out. Open to easier methods as well if there are any.

@echo off
echo WScript.Echo Day(Datepart("d",Now-1))>tmp.vbs
for /f "delims=" %%a in ('cscript /nologo tmp.vbs') do set YDAY=%%a
del /q tmp.vbs
echo Yesterday was %YDAY%

Thank you in advance for your assistance.

KWJ1027
 

try
Code:
@echo off 
echo WScript.Echo Datepart("d",Now()-1)>tmp.vbs 
for /f "delims=" %%a in ('cscript /nologo tmp.vbs') do set YDAY=%%a 
del /q tmp.vbs
echo Yesterday was %YDAY%
 
Replace this:
echo WScript.Echo Day(Datepart("d",Now-1))>tmp.vbs
with this:
echo WScript.Echo Day(Date-1)>tmp.vbs

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Excellent PHV! Works like a charm now appreciate your assistance and time!


KWJ1027
 
Hello PV-

I just happened to be surfing this forum and needed the exact same script but it didn't work for me.. does it need to be run via cscript? at the cmd prompt?

Thanks for any info
geranimo
 
You would run echo WScript.Echo Day(Date-1)>tmp.vbs from the command prompt.

Perhaps specify the path so you know for sure where it is
echo WScript.Echo Day(Date-1)>C:\temp\tmp.vbs

--------------------------------------------------------------------------------
dm4ever
My philosophy: K.I.S.S - Keep It Simple Stupid
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top