troubleshooting Question

Create Numeric Date Variable In A Windows 7 Batch File

Avatar of nss39759
nss39759 asked on
Microsoft DOSShell ScriptingWindows 7
6 Comments1 Solution650 ViewsLast Modified:
Creating a batch file to run on a Windows 7 Professional workstation that creates a folder named with today's date in yyyy-mm-dd format.

The following code snippet successfully returns the year and day, but returns a text abbreviation for the month (e.g. Aug rather than the desired result of 08):

FOR /F "usebackq tokens=1,2,3,4 delims=/ " %%i IN (`date /t`) DO (
set FolderDate=%%l-%%j-%%k
)

This code returns: 2012-Feb-13
The desired output is: 2012-02-13
ASKER CERTIFIED SOLUTION
Bartender_1
Microsoft Network Administrator

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros