Page 1 of 1

Remove / and : in strings

Posted: 04 Aug 2010 23:31
by phillid
Hello again. I am using the %date% and %time% variables in a program, but I need to take the / and the : out of them to leave me with just a number like 21072010. I know that I need to use a FOR loop, but I'm still working on how to use them.
Thanks, guys. :D
phillid

Re: Remove / and : in strings

Posted: 05 Aug 2010 02:07
by !k
Read set/?

Code: Select all

set "var=%var:/=%"

Re: Remove / and : in strings

Posted: 05 Aug 2010 04:29
by jeb
Or you can use it like

Code: Select all

set now=%time%
echo %now:~0,2%_%now:~3,2%_%now:~6,2%


Also, you can read about it with set /? :wink: