Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

To get tomorrow's date

Posted on 2005-04-29
7
Medium Priority
?
2,894 Views
Last Modified: 2011-09-20
I need a MS-DOS Batch file that can help me get tomorrow's date.

Thank You

Need this urgently.
0
Comment
Question by:ben1211
7 Comments
 
LVL 71

Accepted Solution

by:
Chris Dent earned 1000 total points
ID: 13893122

Much easier with VBScript if that's remotely acceptable:

strTomorrow = Date() + 1
wscript.echo strTomorrow

That could easily be called from a batch file or just directly.
0
 
LVL 1

Expert Comment

by:chez88
ID: 13893139
Hi ben1211,

There is a command that allows you to change / show the current date in MS DOS Prompt (type cmd from RUN)

The commands is:
To change/modify current date type : date
To show current date type: date /t

For tomorrow date, i am not sure about this..  =p

Hope it helps,
CHez
0
 
LVL 19

Expert Comment

by:Barthax
ID: 13893207
If it does not need to be a standard DOS component, then you might like to look at DOFF: http://www.jfitz.com/dos/ (DOFF=Date Offset).

The command line is then:

doff dd/mm/yyyy +1
(or however you need it formatting).
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:bmedward
ID: 13896300
sorry, I have to do this...

   echo 4/30/2005
0
 
LVL 9

Expert Comment

by:fixnix
ID: 13896536
LOL bmedward!

Although I was thinking along the lines of:

echo www.lonelylookingforadatetomorrow.com
0
 
LVL 6

Expert Comment

by:bmedward
ID: 13896568
Perhaps a better option, http://www.merlyn.demon.co.uk/programs/nowminus.txt
Documentation is kinda messy - get the nowminus.exe from http://www.merlyn.demon.co.uk/programs/ (http://www.merlyn.demon.co.uk/programs/nowminus.exe --direct link--)

To get tomorrow's date, run nowminus with in the following manner.
     nowminus.exe f01 d-1 r

where:
  nowminus.exe      is the exicutable
  f01                      sets the output to display date only (no time)
  d-1                      tels nowminus to add -1 to the current date.
  r                         makes it output to stdout.
0
 
LVL 4

Expert Comment

by:LittleRed1
ID: 13915154
Just for the record, this batch script will do it for you:
--------------------------------------------------------------------
@echo off
setlocal ENABLEDELAYEDEXPANSION
:: Extract the day, month and year from the date variable
for /f "tokens=2,3,4 delims=/ " %%a in ("%date%") do (
      set day=%%a
      set month=%%b
      set year=%%c
)
:: Note - the sequence of the above will depend on your date format, this is for dd/mm/yyyy

:: Remove preceding zero
if !day! LSS 10 set day=!day:~1!
if !month! LSS 10 set month=!month:~1!

set newday=
:: Calculate whether it's leap year
set leap=no
set /a tmpvar1=!year!/4
set /a tmpvar2=!tmpvar1!*4
if "!tmpvar2!" == "!year!" set leap=yes
set /a tmpvar1=!year!/100
set /a tmpvar2=!tmpvar1!*100
if "!tmpvar2!" == "!year!" set leap=no
set /a tmpvar1=!year!/400
set /a tmpvar2=!tmpvar1!*400
if "!tmpvar2!" == "!year!" set leap=yes

:: Now we do the real work
if "!month!" == "2" (
      if "!leap!" == "yes" if !day! == 29 set newday=1&set /a month=!month!+1
      if "!leap!" == "no" if !day! == 28 set newday=1&set /a month=!month!+1
) else (
      for %%a in (4 6 9 11) do if !month! == %%a if !day! == 30 set newday=1&set /a month=!month!+1
      for %%a in (1 3 5 7 8 10 12) do if !month! == %%a if !day! == 31 set newday=1&set /a month=!month!+1
)
:: Increment year if the end of December
if not "!newday!" == "1" set /a newday=!day!+1
if "!month!" == "13" (
      set month=1
      set /a year=!year!+1
)

:: Re-add preceding zero
if !newday! LSS 10 set newday=0!newday!
if !month! LSS 10 set month=0!month!
echo Tomorrow's date is: !newday!/!month!/!year!
--------------------------------------------------------------------
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As the title indicates, I have done this before. It chills me everytime I update the OS on my phone, (http://www.experts-exchange.com/articles/18084/Upgrading-to-Android-5-0-Lollipop.html) because one time I did this and I essentially had a bricked …
The article covers five tools all IT professionals should know about, as they up productivity by a great deal!
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
Suggested Courses

581 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question