Calendar functions

'Subroutine called calendar
'call this from within the page you want the calendar on.
'make this an include file, or add this code to the page.
<%sub calendar%>
<table width="100%">
<tr>
<td align="center"><%=MonthName(MonthNum)%></td>
</tr>
</table>
<table border="1" cellspacing="0" cellpadding="0">
<tr>
<td height="20" width="20" align="center">S</td>
<td height="20" width="20" align="center">M</td>
<td height="20" width="20" align="center">T</td>
<td height="20" width="20" align="center">W</td>
<td height="20" width="20" align="center">T</td>
<td height="20" width="20" align="center">F</td>
<td height="20" width="20" align="center">S</td>
</tr>
<tr>
<%EmptyDay=1
DayNum=1
do while EmptyDay<BeginningDay%>
<td bgcolor="#CCCCCC" height="20" width="20">&nbsp;</td>
<%EmptyDay=EmptyDay+1
loop
do while EmptyDay<8
ActualDay=MonthNum&"/"&DayNum&"/"&YearNum%>
<td valign="middle" align="center" height="20" width="20" valign="top" <%IF cDate(ActualDay)=date then%> bgcolor="#CCCCFF"<%elseif cDate(ActualDay)=SelectedDay then%> bgcolor="#FF9999"<%end if%>><%=DayNum%></td>
<%DayNum=DayNum+1
EmptyDay=EmptyDay+1
loop%>
</tr>
<%EachWeek=1
do while EachWeek<TotalWeeks
WeekDayNum=0%>
<tr>
<%do while DayNum<TotalDays+1 and WeekDayNum<7
ActualDay=MonthNum&"/"&DayNum&"/"&YearNum%>
<td valign="middle" align="center" height="20" width="20" valign="top" <%IF cDate(ActualDay)=date then%> bgcolor="#CCCCFF"<%elseif cDate(ActualDay)=SelectedDay then%> bgcolor="#FF9999"<%end if%>><%=DayNum%></td>
<%WeekDayNum=WeekDayNum+1
DayNum=DayNum+1
loop
if WeekDayNum<7 then
do while WeekDayNum<7%>
<td height="20" align="center" width="20" bgcolor="#CCCCCC">&nbsp;</td>
<%WeekDayNum=WeekDayNum+1
loop
end if%>
</tr>
<%EachWeek=EachWeek+1
loop%>
</table>
<%end sub%> 'Add this code to the page you want the calendar on. 'this code should appear before the previous code, or the include <%'calendar by Douglas Colley ThisDay=DatePart("d",date) MonthNum=DatePart("m",date) YearNum=DatePart("yyyy",date) SelectedDay=date 'First day of this month falls on this week day number BeginningDay=DatePart("w",cDate(MonthNum&"/1/"&YearNum)) 'showit=MonthNum&"/"&ThisDay&"/"&YearNum 'Number of Total Days in this month if MonthNum = 4 or MonthNum = 6 or MonthNum = 9 or MonthNum = 11 then TotalDays = 30 elseif MonthNum = 2 AND YearNum/4 = int(YearNum/4) then TotalDays = 29 elseif MonthNum = 2 then TotalDays = 28 else TotalDays = 31 end if 'Number of weeks in this month if BeginningDay+TotalDays>35 then TotalWeeks=6 else TotalWeeks=5 end if%>