Link to home
Create AccountLog in
Avatar of Gary Antonellis
Gary AntonellisFlag for United States of America

asked on

Manipulate dates in DOS Bat file

I need to write a 'bat' file that

- gets the current date
- Calculates the date of the previous Monday
- Calculates the date of a week from the current Sunday

For example the current date is 5/16 so the previous Monday value would be 5/13 and the week from Sunday value would be 5/26.

Then build a string that includes the date range in the format:

                     "mm/dd/yyyy_mm/dd/yyyy"
Avatar of Bill Prew
Bill Prew

Does this have to be pure batch, or could a solution that used a small utility (EXE) or a small helper script (VBS) be okay?

Also, if the current day is either Monday, or Sunday could you clarify what day you want calculated in those two "boundary conditions"?

~bp
Was going to respond with VBScript suggestion but will leave you with Bill...

Steve
ASKER CERTIFIED SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Avatar of Gary Antonellis

ASKER

I have not had a chance to test it but it looks like it will work.  If you don't mind I will contact you if there is a problem.

Thanks!
Sure, let me know how you make out.

~bp