Printer Version Table of Contents Project Home Page
.EXAMPLE.....: 25 Determine if a year is valid, and evenly divisible by 4
.CATEGORY....: examples
.DISCUSSION..:
.CODE........:
@echo off
cls
echo FUNCTION: Accept a year parm (CCYY) as parameter 1.  Determine if
echo the year is an election or inauguration year in the United States.
echo ===================================================================

:: verify %1 is a valid year
Fdate /Fv /Imm-dd-ccyy /A01-01-%1 >nul
if errorlevel 1 echo Year parm [%1] is not valid.
if errorlevel 1 goto endit

Fdate /Ff /Imm-dd-ccyy /A01-01-%1 /p"@set year=">junktemp.bat
call junktemp.bat

Fdate /F#mod /A%1 /B4 /p"@set mod=">junktemp.bat
call junktemp.bat
if (%mod%)==(0) echo %1 is an American presidential election year.
if (%mod%)==(1) echo %1 is an American presidential inauguration year.
for %%v in (2 3) do if (%mod%)==(%%v) echo %1 is not an election year.
for %%v in (2 3) do if (%mod%)==(%%v) echo %1 is not an inauguration year.

set mod=

:endit
if exist junktemp.bat del  junktemp.bat