Computing.Net > Forums > Programming > Date variables in Batch programming

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

Date variables in Batch programming

Reply to Message Icon

Name: Batch_Xen
Date: March 4, 2009 at 03:18:09 Pacific
OS: Microsoft Windows Vista Ultimate
CPU/Ram: 3.2 GHz / 3069 MB
Product: Custom / CUSTOM
Subcategory: Batch
Comment:

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!



Sponsored Link
Ads by Google

Response Number 1
Name: Holla
Date: March 4, 2009 at 22:14:55 Pacific
Reply:

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


0

Response Number 2
Name: Holla
Date: March 4, 2009 at 22:39:16 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


report not connecting to ... Renaming file with create...



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Date variables in Batch programming

Date variables in Batch programming www.computing.net/answers/programming/date-variables-in-batch-programming/18085.html

Date Routines in Batch Files www.computing.net/answers/programming/date-routines-in-batch-files/15590.html

%DATE% in batch files with win98 www.computing.net/answers/programming/date-in-batch-files-with-win98/4007.html