Page 1 of 1

dos yesterday's date

Posted: 15 Sep 2009 14:11
by marimo
I know how to return current date like below.


set year=%date:~10,4%
set month=%date:~4,2%
set day=%date:~7,2%

echo %month%-%day%-%year%


but now I need to return yesterday's date. is it possible?

Posted: 15 Sep 2009 19:56
by ghostmachine4
yes its possible to do with batch BUT at the expense of losing your brain cells.
try using vbscript

Code: Select all

DateAdd("d",-1,Now)

Posted: 15 Sep 2009 20:08
by avery_larry
Probably the "easiest" way is dos is to convert to a julian date, subtract 1, and convert back to "normal" date using the various subroutines from this website:


http://www.dostips.com/DtTipsDateTime.php