I would like to set the date in a Windows batch file to 7 days ago from today. I would like to do this in the following format.
set today=%date:~10,4%-%date:~4,2%-%date:~-7,2%
Any ideas how to subract the 7 day time delta here ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I posted the description below in some site some time ago:
The following Batch files convert from Date to Julian Day Number an viceversa:
DATETOJULIAN.BAT:
JULIANTODATE.BAT:
This way, to add/subtract a number of days to a date use the following lines:
Regards…
Reference: http://quasar.as.utexas.edu/BillInfo/JulianDatesG.html
You just need to adjust your date format if it is not MM/DD/YYYY.