I have scripted ShortDate.bat to insure that a short date contains a 4 digit year, two digit month, and 2 digit day.

The syntax for using ShortDate.bat is:

\[Call\] ShortDate iDT iDS sDT YY MM DD

Where:

<b>iDT</b> is your <a href="/article/jsifaq/jsi-tip-10325-how-can-i-determine-the-year-month-and-day-date-order-and-date-separator-.aspx">short date order</a>, retrieved from the <a href="/article/jsifaq/jsi-tip-0311-regional-settings-in-the-registry-.aspx"><b>iDate</b> Value Name</a>.

<b>iDS</b> is your <a href="/article/jsifaq/jsi-tip-10325-how-can-i-determine-the-year-month-and-day-date-order-and-date-separator-.aspx">date separator</a>, retrieved from the <a href="/article/jsifaq/jsi-tip-0311-regional-settings-in-the-registry-.aspx"><b>sDate</b> Value Name</a>.

<b>sDT</b> is the name of the environment variable that contains the short date, which will be 'fixed'.

<b>YY</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 the 4 digit year.

<b>MM</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 the 2 digit month.

<b>DD</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 the 4 digit day.
ShortDate.bat contains:
@echo off
if \{%6\}==\{\} @echo ShortDate iDT iDS sDT YY MM DD&goto :EOF
if \{%1\} GTR \{2\} @echo ShortDate iDT sDT - iDT out of range - %1&goto :EOF
if \{%1\} LSS \{0\} @echo ShortDate iDT sDT - iDT out of range - %1&goto :EOF
setlocal
set iDT=%1
set iDS=%2
call set sDT=%%%3%%
for /f "tokens=1-3 delims=%iDS%" %%a in ('@echo %sDT%') do (
 set d1=20%%a
 set d2=20%%b
 set d3=20%%c
)
goto iDT%iDT%
:iDT0
set YY=%d3:~-4%
set MM=%d1:~-2%
set DD=%d2:~-2%
set sDT=%MM%%iDS%%DD%%iDS%%YY%
goto finish
:iDT1
set YY=%d3:~-4%
set MM=%d2:~-2%
set DD=%d1:~-2%
set sDT=%DD%%iDS%%MM%%iDS%%YY%
goto finish
:iDT2
set YY=%d1:~-4%
set MM=%d2:~-2%
set DD=%d3:~-2%
set sDT=%YY%%iDS%%MM%%iDS%%DD%
:finish
endlocal&set %3=%sDT%&set %4=%YY%&set %5=%MM%&set %6=%DD%