ON 20081213@9:29:02 AM at page: http://techref.massmind.org/techref/method/realtime.htm#39795.395162037 James Newton[JMN-EFP-786] Says /techref/method/month.asp.htm ASP Month Calendar ON 20081213@9:29:49 AM at page: http://techref.massmind.org/techref/method/month.asp.htm#39795.3957060185 James Newton[JMN-EFP-786] Questions: <% wYear=Request.QueryString("wYear") IF wYear = "" THEN wYear=Request.Form("wYear") IF wYear = "" OR wYear < 1753 OR wYear > 9999 THEN wYear = DATEPART("yyyy",now()) wMonth=Request.QueryString("wMonth") IF wMonth = "" THEN wMonth=Request.Form("wMonth") IF wMonth = "" THEN wMonth=DATEPART("m", now()) szMonth = MonthName(wMonth) SET conn=server.createobject("ADODB.connection") conn.Open "DATABASE=[database name];DSN=[DSN Name];UID=[login];Password=[password];" szSQL = "SELECT DATEPART(dd, RecDate) AS DayOfMonth, DATEPART(dw, RecDate) AS WkDay, " & _ "DaysTopCustomer FROM SalesRecords "& _ "WHERE DATEPART(yyyy, RecDate) = " & wYear & "AND DATEPART(mm, RecDate) = " & wMonth & _ " GROUP BY DATEPART(dd, RecDate), DATEPART(dw, RecDate) "& _ "ORDER BY DATEPART(dd, RecDate)" SET rs1=conn.Execute(szSQL) 'INITIALIZE DAY ARRAY lc = 0 dim d(31) for lc = 1 to 31 D(lc) = " " next 'loop through records for the month & assign to D array. DO WHILE NOT rs1.eof 'DAY ASSIGNMENT LOOP TempD = rs1("DayOfMonth") D(TempD) = rs1("DaysTopCustomer") IF NOT rs1.eof THEN rs1.movenext IF rs1.eof then exit do LOOP %> Single Month View of Perpetual Calendar

Subscription Sales

<%=szMonth%>, <%=wYear%>

<% 'Determine day of the week the month begins on tempdate = wMonth & "/1/" & wYear bwdom = datepart("w", tempdate) DayOfWeekCounter = 1 '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 wMonth < 12 THEN ldom = Day(DateAdd("d", -1, wMonth + 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 IF bwdom = 1 AND ldom = 28 THEN NumWeeks = 4 DayCounter = 1 WeekCounter = 1 DO WHILE WeekCounter < NumWeeks + 1 DO WHILE DayOfWeekCounter < 8 IF DayCounter < ldom + 1 THEN %> <%END IF DayOfWeekCounter = DayOfWeekCounter + 1 DayCounter = DayCounter + 1 LOOP DayOfWeekCounter = 1 WeekCounter = WeekCounter + 1 %> <%LOOP%>
Sunday Monday Tuesday Wednesday Thursday Friday Saturday
                     Beginning Day of Week Error
<%=DayCounter%>

  <%=D(DayCounter)%>

<%ELSE%>
 
<%IF wMonth = 1 THEN%> Previous    Next <%ELSEIF wMonth = 12 THEN%> Previous    Next <%ELSE%> Previous    Next <%END IF%>

  Year (1753 to 9999):
Full Year View
ON 20081213@9:30:51 AM at page: http://techref.massmind.org/techref/method/month.asp.htm# James Newton[JMN-EFP-786] edited the page. Difference: http://techref.massmind.org/techref/diff.asp?url=H:\techref\method\month.asp.htm&version=1 ON 20081213@9:31:22 AM at page: http://techref.massmind.org/techref/method/month.asp.htm#39795.3967824074 James Newton[JMN-EFP-786] Code:
<%
wYear=Request.QueryString("wYear")
IF wYear = "" THEN wYear=Request.Form("wYear")
IF wYear = "" OR wYear < 1753 OR wYear > 9999 THEN wYear = DATEPART("yyyy",now())
wMonth=Request.QueryString("wMonth")
IF wMonth = "" THEN wMonth=Request.Form("wMonth")
IF wMonth = "" THEN wMonth=DATEPART("m", now())
szMonth = MonthName(wMonth)

SET conn=server.createobject("ADODB.connection")
conn.Open "DATABASE=[database name];DSN=[DSN Name];UID=[login];Password=[password];"
szSQL = "SELECT DATEPART(dd, RecDate) AS DayOfMonth, DATEPART(dw, RecDate) AS WkDay, " & _
"DaysTopCustomer FROM SalesRecords "& _
	"WHERE DATEPART(yyyy, RecDate) = " & wYear & "AND DATEPART(mm, RecDate) = " & wMonth & _
	" GROUP BY DATEPART(dd, RecDate), DATEPART(dw, RecDate) "& _
	"ORDER BY DATEPART(dd, RecDate)" 
SET rs1=conn.Execute(szSQL)

		'INITIALIZE DAY ARRAY
		lc =  0
		dim d(31)
		for lc = 1 to 31
			D(lc) = "&nbsp;"
		next 
		'loop through records for the month & assign to D array.
		DO WHILE NOT rs1.eof 'DAY ASSIGNMENT LOOP
			TempD = rs1("DayOfMonth")
			D(TempD) = rs1("DaysTopCustomer")
			IF NOT rs1.eof THEN rs1.movenext
			IF rs1.eof then exit do 
		LOOP
%>
<html><HEAD><TITLE>Single Month View of Perpetual Calendar</TITLE></head>
<BODY><CENTER><H2>Subscription Sales</H2><P>
<H1><%=szMonth%>, <%=wYear%></H1><P>
<TABLE ALIGN=center WIDTH=75% BORDER=1 CELLSPACING=1 CELLPADDING=5>
	<TR>
		<TD ALIGN=middle width=14%><STRONG>Sunday</STRONG></TD>
		<TD ALIGN=middle width=14%><STRONG>Monday</STRONG></TD>
		<TD ALIGN=middle width=14%><STRONG>Tuesday</STRONG></TD>
		<TD ALIGN=middle width=14%><STRONG>Wednesday</STRONG></TD>
		<TD ALIGN=middle width=14%><STRONG>Thursday</STRONG></TD>
		<TD ALIGN=middle width=14%><STRONG>Friday</STRONG></TD>
		<TD ALIGN=middle width=14%><STRONG>Saturday</STRONG></TD>
	</TR>
	<TR>
<%		'Determine day of the week the month begins on
		tempdate = wMonth & "/1/" & wYear
		bwdom = datepart("w", tempdate)
		DayOfWeekCounter = 1 

		'PRINT LEADING BLANK DAYS
		SELECT CASE bwdom
			CASE 1 
				DayOfWeekCounter = 1
			CASE 2 %>
				<TD>&nbsp;</TD><%DayOfWeekCounter = 2
			CASE 3 %>
				<TD>&nbsp;</TD><TD>&nbsp;</TD><%DayOfWeekCounter = 3
			CASE 4 %>
				<TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><%DayOfWeekCounter = 4
			CASE 5 %>
				<TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><%DayOfWeekCounter = 5
			CASE 6 %>
				<TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><%DayOfWeekCounter = 6
			CASE 7 %>
				<TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><TD>&nbsp;</TD><%DayOfWeekCounter = 7
			CASE ELSE %>
				<TD>Beginning Day of Week Error</TD><%
		END SELECT

		'Determine last day of month & number of weeks
		IF wMonth < 12 THEN
			ldom = Day(DateAdd("d", -1, wMonth + 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
		IF bwdom = 1 AND ldom = 28 THEN NumWeeks = 4
		
		DayCounter = 1
		WeekCounter = 1
		DO WHILE WeekCounter < NumWeeks + 1
			DO WHILE DayOfWeekCounter < 8	
				IF DayCounter < ldom + 1 THEN %>
					<TD ALIGN=left>
					<TABLE ALIGN=center width=100% BORDER=0 CELLSPACING=0 CELLPADDING=0>
						<TR><TD align=left><STRONG><%=DayCounter%></STRONG>
						</TR><TR>
						<TD align=center><H2><FONT color=ff0000>&nbsp;&nbsp;<%=D(DayCounter)%></FONT></H2>
					</TR></TABLE>
				<%ELSE%>
					<TD ALIGN=middle>&nbsp;</TD>
				<%END IF
				DayOfWeekCounter = DayOfWeekCounter + 1 
				DayCounter = DayCounter + 1 
			LOOP
			DayOfWeekCounter = 1
			WeekCounter = WeekCounter + 1 %>
			</TR><TR>
		<%LOOP%>
</TABLE>
<%IF wMonth = 1 THEN%>
	<a href="month.asp?wMonth=12%>&wYear=<%=(wYear-1)%>">Previous</a>&nbsp;&nbsp;&nbsp;
	<a href="month.asp?wMonth=<%=(wMonth+1)%>&wYear=<%=wYear%>">Next</a>
<%ELSEIF wMonth = 12 THEN%>
	<a href="month.asp?wMonth=<%=(wMonth-1)%>&wYear=<%=wYear%>">Previous</a>&nbsp;&nbsp;&nbsp;
	<a href="month.asp?wMonth=1&wYear=<%=(wYear+1)%>">Next</a>
<%ELSE%>
	<a href="month.asp?wMonth=<%=(wMonth-1)%>&wYear=<%=wYear%>">Previous</a>&nbsp;&nbsp;&nbsp;
	<a href="month.asp?wMonth=<%=(wMonth+1)%>&wYear=<%=wYear%>">Next</a>
<%END IF%>
<FORM action="month.asp" method="post" id=form1 name=form1>
	<SELECT name="wMonth" size="1">
		<%IF wMonth = 1 THEN %>
			<option selected value="1">January</option>
		<%ELSE%>
			<option value="1">January</option>
		<%END IF%>
		<%IF wMonth = 2 THEN %>
			<option selected value="2">February</option>
		<%ELSE%>
			<option value="2">February</option>
		<%END IF%>
		<%IF wMonth = 3 THEN %>
			<option selected value="3">March</option>
		<%ELSE%>
			<option value="3">March</option>
		<%END IF%>
		<%IF wMonth = 4 THEN %>
			<option selected value="4">April</option>
		<%ELSE%>
			<option value="4">April</option>
		<%END IF%>
		<%IF wMonth = 5 THEN %>
			<option selected value="5">May</option>
		<%ELSE%>
			<option value="5">May</option>
		<%END IF%>
		<%IF wMonth = 6 THEN %>
			<option selected value="6">June</option>
		<%ELSE%>
			<option value="6">June</option>
		<%END IF%>
		<%IF wMonth = 7 THEN %>
			<option selected value="7">July</option>
		<%ELSE%>
			<option value="7">July</option>
		<%END IF%>
		<%IF wMonth = 8 THEN %>
			<option selected value="8">August</option>
		<%ELSE%>
			<option value="8">August</option>
		<%END IF%>
		<%IF wMonth = 9 THEN %>
			<option selected value="9">September</option>
		<%ELSE%>
			<option value="9">September</option>
		<%END IF%>
		<%IF wMonth = 10 THEN %>
			<option selected value="10">October</option>
		<%ELSE%>
			<option value="10">October</option>
		<%END IF%>
		<%IF wMonth = 11 THEN %>
			<option selected value="11">November</option>
		<%ELSE%>
			<option value="11">November</option>
		<%END IF%>
		<%IF wMonth = 12 THEN %>
			<option selected value="12">December</option>
		<%ELSE%>
			<option value="12">December</option>
		<%END IF%>
    </SELECT>&nbsp;
    Year (1753 to 9999): <input size=6 maxlength=4 name=wYear value=<%=wYear%>>&nbsp;
	<input type="submit" name="Jump" VALUE="Jump">
</form>
<a href="calendar.asp">Full Year View</a>
</center></BODY></HTML>
ON 20081213@9:32:56 AM at page: http://techref.massmind.org/techref/method/realtime.htm# James Newton[JMN-EFP-786] edited the page. Difference: http://techref.massmind.org/techref/diff.asp?url=H:\techref\method\realtime.htm&version=1 ON 20081213@9:34:41 AM at page: http://techref.massmind.org/techref/method/realtime.htm#39795.3990740741 James Newton[JMN-EFP-786] Says /techref/method/stdcal.asp.htm ASP Standard Calendar ON 20081213@9:45:13 AM at page: http://techref.massmind.org/techref/method/stdcal.asp.htm#39795.4063888889 James Newton[JMN-EFP-786] Code:
<%@ 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())
%>
<html><HEAD><TITLE>SQL Calendar</TITLE></head>
<BODY><CENTER>
<form action="calendar.asp" method="post">
	Enter a year from 1753 to 9999:<br>
	<input size=6 maxlength=4 name=wYear><br>
	<input type="submit" name="Change" VALUE="Change">
</form><BR>
<H2><%=wYear%> Calendar</H2><P>
<TABLE ALIGN=center WIDTH=30% BORDER=1 CELLSPACING=1 CELLPADDING=2>
	<TR>
		<TD ALIGN=middle></TD>
		<TD ALIGN=middle><STRONG>Sun.</STRONG></TD>
		<TD ALIGN=middle><STRONG>Mon.</STRONG></TD>
		<TD ALIGN=middle><STRONG>Tue.</STRONG></TD>
		<TD ALIGN=middle><STRONG>Wed.</STRONG></TD>
		<TD ALIGN=middle><STRONG>Thu.</STRONG></TD>
		<TD ALIGN=middle><STRONG>Fri.</STRONG></TD>
		<TD ALIGN=middle><STRONG>Sat.</STRONG></TD>
	</TR>
<%
mc = 0 
FOR mc = 1 TO 12 %>
	<TR>
		<TD ALIGN=middle><STRONG><%=MonthName(mc)%></STRONG></TD>
		<%
		'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 %>
				<TD></TD><%DayOfWeekCounter = 2
			CASE 3 %>
				<TD></TD><TD></TD><%DayOfWeekCounter = 3
			CASE 4 %>
				<TD></TD><TD></TD><TD></TD><%DayOfWeekCounter = 4
			CASE 5 %>
				<TD></TD><TD></TD><TD></TD><TD></TD><%DayOfWeekCounter = 5
			CASE 6 %>
				<TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><%DayOfWeekCounter = 6
			CASE 7 %>
				<TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><TD></TD><%DayOfWeekCounter = 7
			CASE ELSE %>
				<TD>Beginning Day of Week Error</TD><%
		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 %>
					<TD ALIGN=middle><STRONG><%=DayCounter%></STRONG></TD>
					<% 'IF statements for holidays and anniversaries goes here. %>
				<%ELSE%>
					<TD ALIGN=middle></TD>
				<%END IF
				DayOfWeekCounter = DayOfWeekCounter + 1 
				DayCounter = DayCounter + 1 
			LOOP
			DayOfWeekCounter = 1
			WeekCounter = WeekCounter + 1 %>
			</TR><TR><TD></TD>
		<%LOOP%>
<%NEXT%>
</TABLE><P>
</center></BODY></HTML>