www.rodneybeede.com "I would love to change the world, but they won't give me the source code" - unknown

Windows Batch Script - Parsing Date Into Components (Month, Day, Year) - Last Modified 2008-09-26 23:15 UTC - Created 2008-09-26 23:15 UTC

I found a U.S. locale specific way to parse a date into components inside a Windows batch script (.bat or .cmd).

@REM Valid only for U.S. (English) locale
FOR /F "tokens=2-4 delims=/ " %%i IN ('echo %date%') DO SET MONTH=%%i& SET DAY=%%j& SET YEAR=%%k

Again it only works for the U.S. locale (and similiar). If you need something that works regardless of locale there are other examples that do it in a batch script, but you should really consider an external .com or .exe that inserts it into your batch script (Google it) or use a Windows Scripting Host script instead.