Windows XPPost your Windows XP related questions here.
Mission Statement
WindowsBBS is an online community dedicated to easily accessible technical support for those using Microsoft operating systems and other Windows software.
Our goal is to become the leading resource for computer users that require assistance with their day-to-day computer usage, including full support for networking PC's, virus & malware removal, system upgrades and general support questions.
FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%J%%K%%L
ECHO The value is "%mydate%"
This is strictly for Windows XP and 2000; it won't work on Windows 9x platforms. Note that the middle line is long and maybe word-wrapped in print. It begins with the word FOR and ends with %%L.
..........
DATE /t returns the current date in a form like "Thu 03/25/2004". The tokens= and delims= entries determine how the string will be parsed. Here the delimiters are slash and space, and we have requested tokens 1 through 4. The defined FOR variable %%I gets the first token, which is the day of the week (not used here). The remaining tokens are automatically assigned to the next three letter variables, J, K, and L. By combining them, we get the date in the desired form, such as03252004 .
You can incorporate this command into any batch file—even change the order of the date elements or insert other characters. For example, by ending the line with SET mydate =%%L-%%J-%%K you'd get a sortable yyyy-mm-dd date.
I created a batch file:
jld.bat
FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%J%%K%%L
ECHO The value is "%mydate%"
It returns "the value is" 042007
Not "07042007"
However if I change the file to read:
FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%I%%J%%K%%L
I added the "%%I" to the string
it returns the value = "07042007"
I would like the returned value to be:"20070704"
It used to work as I want, but something has changed....the only place that I have dinked around is in CP - region settings, I set time to display 24h clock.
Any insight is gretly appreciated.
Didn't find the information you thought to find? Check out these Similar Threads
Date setting in CP - Regional & language - Customize date
short date format = M/d/yyyy ( works like it is supposed to )
I had MM/dd/yyyy - and it don't work.......
FOR /F "tokens=1-4 delims=/ " %%I IN ('DATE /t') DO SET mydate=%%L%%J%%K
ECHO The value is "%mydate%"
returns:
20070704
sorry for any inconvenience
regards:captjlddavis
Last edited by captjlddavis; 5th July 2007 at 09:17.