@echo off SET DateStr=%~2&if "%~2"=="" set DateStr=%date% FOR /F "skip=1 tokens=2-4 delims=(-)" %%a IN ('"echo.|date"') DO ( FOR /F "TOKENS=1-3 DELIMS=/.- " %%A IN ("%DateStr:* =%") DO ( SET %%a=%%A&set %%b=%%B&set %%c=%%C)) SET /A "yy=10000%yy% %%10000,mm=100%mm% %% 100,dd=100%dd% %% 100" SET /A JD=dd-32075+1461*(yy+4800+(mm-14)/12)/4+367*(mm-2-(mm-14)/12*12)/12-3*((yy+4900+(mm-14)/12)/100)/4 IF "%~1" NEQ "" (SET %~1=%JD%) ELSE (SET /P ".=%JD%"