If, after reading other questions and looking at the links mentioned in the comment sections, you still cannot figure it out, continue reading.
First of all, if you go wrong, this is an offset.
It should look something like this ...
set mydate=%date:~10,4%%date:~6,2%/%date:~4,2% echo %mydate%
If the date was Tue 12/02/2013 , it would display as 2013/02/12 . to remove slashes, the code will look more like set mydate=%date:~10,4%%date:~7,2%%date:~4,2% , which will output 20130212
And a hint for doing this in the future, if mydate is equal to something like %date:~10,4%%date:~7,2% or the like, you probably forgot the tilde (~).
BDM Feb 12 '13 at 6:07 2013-02-12 06:07
source share