Discussion Locked

capture today's date in a variable?

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am trying to rename my backup file to include today's date in a script and run as a *.bat file.
set /a today=%date/t%
set /a today=date/t
set today=date
all did not work.

Can you shed some light on this?

thanks
andrew

2 replies

by pvp

You can get date components like this:

for /f "tokens=1,2,3,4* delims=/ " %%i in ('date /t') do set TDDAY=%%i&set TDMM=%%j&set TDDD=%%k&set TDYY=%%l

This isn't originally mine, but is free and PD. For more info and code to steal, visit http://www.jsiinc.com, click on NT Reg Hacks, then search for date.

This discussion is closed to new replies.