Hi,
For /f "tokens=2-4 delims=/ " %%a in ('date /t') do (set mydate=%%c%%a%%b)
Here mydate gives 2018419 which is YYYYMMDD format.
I want the date format in YYMMDD. Please see, if this is possible in the above code.
I tried below and it works.
Set mydate=%date:~-2%%date:~4,2%%date:~7,2%
This gives the format YYMMDD which I want. Just looking for the above one, if can give YYMMDD.
Thank you!
Need help in date format
Moderator: DosItHelp
Re: Need help in date format
Code: Select all
echo %date:~-2,4%%date:~-10,2%%date:~-7,2%
pause
Code: Select all
FOR /F "tokens=1-2 delims=/:" %%A IN ("%TIME%") DO ( SET TIMESTAMP=%%A%%B)
FOR /F "tokens=* delims= " %%C IN ("%TIMESTAMP%") DO ( SET TIMESTAMP=%%C)
SET "DATETIME=%date:~-2,4%%date:~-10,2%%date:~-7,2%_%TIMESTAMP%"
echo %DATETIME%
pause