Page 1 of 1

please explain me this

Posted: 01 Dec 2010 10:43
by Mohammad_Dos
Hi, this is for make a directory with name of date:


Set MM=%date:~4,2%
Set DD=%date:~7,2%
Set YYYY=%date:~-4%
md %YYYY%-%MM%-%DD%


please explain me this


%date:~4,2% ?!!!!!!
%date:~7,2% ???????!!!!!!
%date:~-4% ؟؟؟؟؟؟!!!!

Re: please explain me this

Posted: 01 Dec 2010 13:08
by aGerman
This method is not safe.
Check the output of

Code: Select all

echo %date%

If you find something like ...
Wed 12/01/2010

... it would work for you.

The next 2 characters after the 4th is the month.
The next 2 characters after the 7th is the day.
The last 4 characters is the year.

For additional informations type SET /? to the command prompt.

Regards
aGerman