Date variables in Batch programming

Custom / CUSTOM
March 4, 2009 at 03:18:09
Specs: Microsoft Windows Vista Ultimate, 3.2 GHz / 3069 MB
Hi, guys... I have a certain problem, but to be more inlighting i will post my code and explain the problem beyond.

C:\CLmailer\CLmailer 
/server:smtp.myserver.gr
/to:reciever@recieve.gr /from:sender@send.gr 
/subject:"my subject  %date% and %????%" /body:"my body %date% and after %?????%" 

the %????% is what i am looking for!!!!

Into this code i call an application, the CLmailer, which sends the email... It sends the email including the subject, body, to etc. into the subject and the body, except of my comments, i want to be sent extra info the current date and the date 5 days after the current. I have achieved only the current date, by the %date% command, but i cannot figure out the command of the date 5 days after the current... I'm looking forward some discussion and solves on the issue!


See More: Date variables in Batch programming

Report •


#1
March 4, 2009 at 22:14:55
echo date %date% > save-cur-date.bat
echo time %time% > save-cur-time.bat
time 23:59:59
:delay 2 secs so that date changed to tomorrow.
ping -n 2 127.0.0.1 > nul
time 23:59:59
:delay 2 secs so that date changed to day 2.
ping -n 2 127.0.0.1 > nul
:delay 2 secs so that date changed to day 3.
ping -n 2 127.0.0.1 > nul
:delay 2 secs so that date changed to day 4.
ping -n 2 127.0.0.1 > nul
:delay 2 secs so that date changed to day 5.
ping -n 2 127.0.0.1 > nul
set day5=%date%
call save-cur-date.bat
call save-cur-time.bat
:Now you have the day5 date in varilable %day5%

:In the process computer's time will be delayed by 10 seconds :-(

--
Holla.

EDIT: See the solution in next post, which is better


Report •

#2
March 4, 2009 at 22:39:16
This is little better and eats up negligible time off the computer.
@echo off
set saveCurDate=%date%
set saveCurTime=%time%
for /l %%I in (1,1,5) do call :NextDay
set day5=%date%
date %saveCurDate%
time %saveCurTime%
echo Now you have the day5 date in varilable day5 (%day5%)
goto :eof
:NextDay
set oldDay=%date%
time 23:59:59.99
:Loop
if %oldDay%==%date% goto Loop
goto :eof


--
Holla.


Report •

Related Solutions


Ask Question