dos yesterday's date

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
marimo
Posts: 4
Joined: 05 Aug 2009 12:31

dos yesterday's date

#1 Post by marimo » 15 Sep 2009 14:11

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?

ghostmachine4
Posts: 319
Joined: 12 May 2006 01:13

#2 Post by ghostmachine4 » 15 Sep 2009 19:56

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)

avery_larry
Expert
Posts: 391
Joined: 19 Mar 2009 08:47
Location: Iowa

#3 Post by avery_larry » 15 Sep 2009 20:08

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

Post Reply