Thursday, January 25, 2007

Windows NT XP 2003 DOS Batch Get Date as Variables

I use the following dos batch file, this is helpful when generating log files, that you want time stamped.

rem works with windows 2003 and xp
@echo off
for /f "tokens=1-4 delims=/ " %%a in ('date /t') do (set weekday=%%a& set month=%%b& set day=%%c& set year=%%d)

echo day = %day%
echo month = %month%
echo year = %year%

echo %year%%month%%day%