I have scripted DaysMonth.bat to return the number of days in the month for a specified date.

The syntax for using DaysMonth.bat is:

\[call\] DaysMonth Date Days


<b>Date</b> contains a valid date.

<b>Days</b> is a <a href="/article/tips/tip.aspx?id=5535">call directed numeric environment variable</a> that will contain the
 number of days in the month for <b>Date</b>.
DaysMonth.bat contains:
@echo off
if \{%2\}==\{\} @echo DaysMonth Date Days&goto :EOF
if exist "%TEMP%\DaysMonth.vbs" goto doit
@echo.Dim Arguments>"%TEMP%\DaysMonth.vbs"
@echo.Set Arguments = Wscript.Arguments>>"%TEMP%\DaysMonth.vbs"
@echo.yyyy = DatePart("yyyy", Arguments(0))>>"%TEMP%\DaysMonth.vbs"
@echo.mm = Right(100+DatePart("m", Arguments(0)),2)>>"%TEMP%\DaysMonth.vbs"
@echo.ld = Day(DateSerial(yyyy, 1 + mm, 0))>>"%TEMP%\DaysMonth.vbs"
@echo.wScript.Echo ld>>"%TEMP%\DaysMonth.vbs"
set /a %2=0
for /f "Tokens=*" %%a in ('cscript //nologo "%TEMP%\DaysMonth.vbs" %1') do (
 set /a %2=%%a