I had previously scripted sDate.bat as 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.

Date2YMD.bat is a faster method, that does NOT require the script to explicitly access the registry.

The syntax for using Date2YMD.bat is:

call Date2YMD ShortDate Year Month Day

Where:

<b>ShortDate</b> is the short date that you wish to enumerate.
<b>Year</b>      is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain <b>ShortDate</b>'s 4 digit year.
<b>Month</b>     is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain <b>ShortDate</b>'s 2 digit month.
<b>Day</b>       is a <a href="/article/jsifaq/jsi-tip-5535-how-can-i-cause-a-called-batch-file-to-return-a-call-directed-environment-variable-.aspx">call directed environment variable</a> that will contain <b>ShortDate</b>'s 2 digit day.
Date2YMD.bat contains:
@echo off
if \{%4\}==\{\} @echo Syntax: Date2YMD ShortDate Year Month Day&goto :EOF
if exist "%TEMP%\Date2YMD.vbs" goto :doit
@echo Dim Arguments, sd>"%TEMP%\Date2YMD.vbs"
@echo Set Arguments = Wscript.Arguments>>"%TEMP%\Date2YMD.vbs"
@echo sd = Arguments(0)>>"%TEMP%\Date2YMD.vbs"
@echo yyyy = DatePart("yyyy", sd)>>"%TEMP%\Date2YMD.vbs"
@echo m = Right(100+DatePart("m", sd),2)>>"%TEMP%\Date2YMD.vbs"
@echo d = Right(100+DatePart("d", sd),2)>>"%TEMP%\Date2YMD.vbs"
@echo Wscript.Echo yyyy ^& " " ^& m ^& " " ^& d>>"%TEMP%\Date2YMD.vbs"
:doit
for /f "Tokens=1-3" %%a in ('cscript //nologo "%TEMP%\Date2YMD.vbs" %1') do (
 set %2=%%a
 set %3=%%b
 set %4=%%c
)
endlocal