<%@ LANGUAGE=VBScript %> <% wYear=Request.QueryString("wYear") IF wYear = "" THEN wYear=Request.Form("wYear") IF wYear = "" OR wYear < 1753 OR wYear > 9999 THEN wYear = DATEPART("yyyy",now()) %> SQL Calendar
Enter a year from 1753 to 9999:


<%=wYear%> Calendar

<% mc = 0 FOR mc = 1 TO 12 %> <% 'Determine day of the week the month begins on tempdate = mc & "/1/" & wYear bwdom = datepart("w", tempdate) DayOfWeekCounter = 0 'This "week" has 8 "days" to include the Name of the Month column. 'PRINT LEADING BLANK DAYS SELECT CASE bwdom CASE 1 DayOfWeekCounter = 1 CASE 2 %> <%DayOfWeekCounter = 2 CASE 3 %> <%DayOfWeekCounter = 3 CASE 4 %> <%DayOfWeekCounter = 4 CASE 5 %> <%DayOfWeekCounter = 5 CASE 6 %> <%DayOfWeekCounter = 6 CASE 7 %> <%DayOfWeekCounter = 7 CASE ELSE %> <% END SELECT 'Determine last day of month & number of weeks IF mc < 12 THEN ldom = Day(DateAdd("d", -1, mc + 1 & "/1/" & wYear)) ELSE ldom = Day(DateAdd("d", -1, "1/1/" & wYear + 1)) END IF NumWeeks = 5 IF (bwdom = 6 AND ldom = 31) OR (bwdom = 7 AND ldom > 29) THEN NumWeeks = 6 DayCounter = 1 WeekCounter = 1 DO WHILE WeekCounter < NumWeeks + 1 DO WHILE DayOfWeekCounter < 8 IF DayCounter < ldom + 1 THEN %> <% 'IF statements for holidays and anniversaries goes here. %> <%ELSE%> <%END IF DayOfWeekCounter = DayOfWeekCounter + 1 DayCounter = DayCounter + 1 LOOP DayOfWeekCounter = 1 WeekCounter = WeekCounter + 1 %> <%LOOP%> <%NEXT%>
Sun. Mon. Tue. Wed. Thu. Fri. Sat.
<%=MonthName(mc)%>Beginning Day of Week Error<%=DayCounter%>