NOTE: See Another way to return a 4 digit year, 2 digit month, and 2 digit day from a short date, regardless of your short date format..

I have scripted iDateYMD.bat to return a short date's 4 digit year, 2 digit month, and 2 digit day, regardless of your short date format.

iDateYMD.bat retrieves your date format from the iDate Value Name, using REG.EXE, built into Windows XP and Windows Server 2003, or REG.EXE from the Windows 2000 Support Tools on the CD-ROM, which must be available in your PATH.

The syntax for using iDateYMD.bat is:

\[call\] iDateYMD sDate YYYY MM DD

Where:

sDate is the short date that you wish to enumerate.
YYYY  is a call directed environment variable that will contain sDate's 4 digit year.
MM    is a call directed environment variable that will contain sDate's 2 digit month.
DD    is a call directed environment variable that will contain sDate's 2 digit day.
iDateYMD.bat contains:
@echo off
if \{%4\}==\{\} @echo Syntax: iDateYMD sDate YYYY MM DD&goto :EOF
setlocal
for /f "tokens=1-3 delims=.:/-, " %%x in ('@echo %1') do (
 set /a p1=10000%%x%%10000
 set /a p2=10000%%y%%10000
 set /a p3=10000%%z%%10000
)
if %p1% LSS 10 set p1=0%p1%
if %p2% LSS 10 set p2=0%p2%
if %p3% LSS 10 set p3=0%p3%
set df=3
for /f "Tokens=2,3" %%x in ('REG QUERY "HKCU\Control Panel\International" /V iDate^|find /i "REG_SZ"') do set df=%%y
if "%df%" EQU "0" set MM=%p1%&set DD=%p2%&set YY=%p3%&goto dayn
if "%df%" EQU "1" set DD=%p1%&set MM=%p2%&set YY=%p3%&goto dayn
if "%df%" EQU "2" set YY=%p1%&set MM=%p2%&set DD=%p3%&goto dayn
set YY=0000&set MM=00&set DD=00
:dayn
endlocal&set %2=%YY%&set %3=%MM%&set %4=%DD%