I have a batch file which creates today's date just fine. Now I need to update it to show tomorrow's date. Any help is much appreciated:
@echo off
set TimeStamp=12:00:00
FOR /F "TOKENS=1* DELIMS= " %%A IN ('DATE/T') DO SET CDATE=%%B
FOR /F "TOKENS=1,2 eol=/ DELIMS=/ " %%A IN ('DATE/T') DO SET mm=%%B
FOR /F "TOKENS=1,2 DELIMS=/ eol=/" %%A IN ('echo %CDATE%') DO SET dd=%%B
FOR /F "TOKENS=2,3 DELIMS=/ " %%A IN ('echo %CDATE%') DO SET yyyy=%%B
SET date="%yyyy%-%mm%-%dd% %TimeStamp%"
echo %date%
The 'problem' is that you need to think about February, leap-years, etc.
Paul Tomasi has posted a rather brilliant script on his site where he explains it completely, even including a flowchart.
::================================================
:: TOMORROW.BAT - Written by Paul Tomasi (c)2010
::
:: Function to return tomorrow's date
::================================================
@echo off
set /a d=%date:~0,2%
set /a m=%date:~3,2%
set /a y=%date:~6,4%
:loop
set /a d+=1
if %d% gtr 31 (
set d=1
set /a m+=1
if %m% gtr 12 (
set m=1
set /a y+=1
)
)
xcopy /d:%m%-%d%-%y% /h /l "%~f0" "%~f0\" >nul 2>&1 || goto loop
echo %d%/%m%/%y%
::------------------------------------------------
So it's either this, or diving into hybrid batch-scripts.
Hope this helps!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With