I'm having a really bizarre problem with a calendar page I wrote 2 years ago.
Though it still works perfectly well on IIS in XP here, on the server the day of the week on which each month starts is now totally out of whack. There may be a pattern, but I cannot see it.
Obviously there must be a different version of IIS running on the server or something and the code needs tweaking, but whatever I try I can't get it.
Any ideas?
Here is code:
-------------------------------
<style type="text/css">
.box A:link {
color: #40775F;
TEXT-DECORATION: none;
}
.box A:visited {
color: #40775F;
TEXT-DECORATION: none;
}
.box A:hover {
color: #981001;
TEXT-DECORATION:underline;
}
.box A:active {
color: #981001;
TEXT-DECORATION:underline;
}
.box3 A:link {
color: #ffb901;
TEXT-DECORATION: none;
}
.box3 A:visited{
color: #ffb901;
TEXT-DECORATION: none;
}
.box3 A:hover{
color: #ffb901;
TEXT-DECORATION: underline;
}
.box3 A:active{
color: #ffb901;
TEXT-DECORATION: underline;
}
</style>
<title>Calendar</title>
</head>
<body>
<%
Function FixNull(v)
if isNull(v) then
FixNull = ""
Else
FixNull = v
End If
End Function
Function NameFromMonth(iMonth)
select case cint(iMonth)
case 1
s = "January"
case 2
s = "February"
case 3
s = "March"
case 4
s = "April"
case 5
s = "May"
case 6
s = "June"
case 7
s = "July"
case 8
s = "August"
case 9
s = "September"
case 10
s = "October"
case 11
s = "November"
case 12
s = "December"
end select
NameFromMonth = s
End Function
Function LastDay(testYear, testMonth)
LastDay = Day(DateSerial(testYear, testMonth + 1, 0))
End Function
Function GetPrevMonth(iThisMonth,iThisYear)
GetPrevMonth=month(dateserial(iThisYear,iThisMonth,1)-1)
End Function
Function GetPrevMonthYear(iThisMonth,iThisYear)
GetPrevMonthYear=Year(dateserial(iThisYear,iThisMonth,1)-1)
End Function
Function GetNextMonth(iThisMonth,iThisYear)
GetNextMonth=month(dateserial(iThisYear,iThisMonth+1,1))
End Function
Function GetNextMonthYear(iThisMonth,iThisYear)
GetNextMonthYear=year(dateserial(iThisYear,iThisMonth+1,1))
End Function
%>
<table border="0" cellpadding="20" cellspacing="0" width="100%" class="box">
<tr>
<td width="100%" align="center">
<table border="1" cellpadding="10" cellspacing="10" width="100%" bordercolor="#DECEB5">
<tr>
<td width="100%">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100%" colspan="3">
<font size='2' FACE='Arial,Helvetica'><B>Instructions: </B>Click on the date to
enquire, unless unavailable</FONT><HR NOSHADE>
</td>
</tr>
<tr>
<td colspan="2" height="50">
<b><font face="Arial" size="2">
Legend</font></b>
</td>
<td rowspan="6" valign="top">
<%
iMonth=Request.QueryString ("Month")
iYear=Request.QueryString ("Year")
iapt=Request.QueryString ("apt")
if trim(iMonth) = "" then iMonth = Month(Now)
sMonth=NameFromMonth(iMonth)
if trim(iYear) = "" then iYear = Year(Now)
Response.Write ("<center><b><font size='3' FACE='Arial,Helvetica'> ")
Response.Write ("<a href='calendar.asp?apt=" & iapt & "&month=" & GetPrevMonth(iMonth,iYear) & "&year=" & GetPrevMonthYear(iMonth,iYear) & "'><<</a>" & " ")
Response.Write ( sMonth & ", " & iYear & " " )
Response.Write ("<a href='calendar.asp?apt=" & iapt & "&month=" & GetNextMonth(iMonth,iYear) & "&year=" & GetNextMonthYear(iMonth,iYear) & "'>>></a><br></b></font><br>")
%>
<table border="0">
<tr>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Sun</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Mon</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Tue</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Wed</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Thu</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Fri</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Sat</b></font></td>
</tr>
<%
set conn = Server.CreateObject("ADODB.Connection")
set cmd = Server.CreateObject("ADODB.Command")
set rs = Server.CreateObject("ADODB.Recordset")
'conn.mode = 3
conn.open strconn
set cmd.activeconnection = conn
i = 0
iLastDay = LastDay(iYear, iMonth)
iFirstDay= Weekday(CDate(imonth & "/01/" & iYear))
iLastDay = iFirstDay + iLastDay - 1
do while i<= iLastDay
if i <> iLastDay then
Response.Write ("<tr>")
else
exit do
end if
for j=1 to 7
if (j < iFirstDay and i = 0) or (i + j > iLastDay) then
Response.Write ("<td width='40' height='25' valign='top' bgcolor='#c0c0c0' NOWRAP></td>")
else
k = k + 1
sDate = "#" & imonth & "/" & k & "/" & iYear & "#"
set rs = conn.execute("SELECT * FROM booking WHERE " & sDate & " >= adate AND " & sDate & " <= bdate")
if rs.eof then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
else
if Request.QueryString("apt") = "college" then
if rs("confirmed")=True and rs("college")=-1 then
slink = ""
sbgcolor = "#981001"
sfont = "#ffffff"
sclass = ""
end if
if rs("confirmed")=false and rs("college")=-1 then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = "#40775F"
sfont = ""
sclass = "box3"
end if
if rs("college")=false then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
end if
elseif Request.QueryString("apt") = "custom" then
if rs("confirmed")=True and rs("custom")=-1 then
slink = ""
sbgcolor = "#981001"
sfont = "#ffffff"
sclass = ""
end if
if rs("confirmed")=false and rs("custom")=-1 then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = "#40775F"
sfont = ""
sclass = "box3"
end if
if rs("custom")=false then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
end if
elseif Request.QueryString("apt") = "herb" then
if rs("confirmed")=True and rs("herb")=-1 then
slink = ""
sbgcolor = "#981001"
sfont = "#ffffff"
sclass = ""
end if
if rs("confirmed")=false and rs("herb")=-1 then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = "#40775F"
sfont = ""
sclass = "box3"
end if
if rs("herb")=false then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
end if
elseif Request.QueryString("apt") = "ball" then
if rs("confirmed")=True and rs("ball")=-1 then
slink = ""
sbgcolor = "#981001"
sfont = "#ffffff"
sclass = ""
end if
if rs("confirmed")=false and rs("ball")=-1 then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = "#40775F"
sfont = ""
sclass = "box3"
end if
if rs("ball")=false then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
end if
elseif Request.QueryString("apt") = "ifsc" then
if rs("confirmed")=True and rs("ifsc")=-1 then
slink = ""
sbgcolor = "#981001"
sfont = "#ffffff"
sclass = ""
end if
if rs("confirmed")=false and rs("ifsc")=-1 then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = "#40775F"
sfont = ""
sclass = "box3"
end if
if rs("ifsc")=false then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
end if
end if
end if
Response.Write ("<td width='40' height='25' valign='top' bgcolor='" & sbgcolor & "' class='" & sclass & "'><font face='century gothic' size='3' color='" & sfont & "'>")
Response.Write "<B> "
Response.Write slink
Response.write k & "</A></B>" & sEvent
Response.Write ("</td>")
end if
next
i=i+7
loop
Response.Write ("</tr>")
%>
<%
if rs.state <> 0 then rs.close
set rs = nothing
set cmd = nothing
conn.close
set conn = nothing
%>
</table>
-----------------------------
Though it still works perfectly well on IIS in XP here, on the server the day of the week on which each month starts is now totally out of whack. There may be a pattern, but I cannot see it.
Obviously there must be a different version of IIS running on the server or something and the code needs tweaking, but whatever I try I can't get it.
Any ideas?
Here is code:
-------------------------------
<style type="text/css">
.box A:link {
color: #40775F;
TEXT-DECORATION: none;
}
.box A:visited {
color: #40775F;
TEXT-DECORATION: none;
}
.box A:hover {
color: #981001;
TEXT-DECORATION:underline;
}
.box A:active {
color: #981001;
TEXT-DECORATION:underline;
}
.box3 A:link {
color: #ffb901;
TEXT-DECORATION: none;
}
.box3 A:visited{
color: #ffb901;
TEXT-DECORATION: none;
}
.box3 A:hover{
color: #ffb901;
TEXT-DECORATION: underline;
}
.box3 A:active{
color: #ffb901;
TEXT-DECORATION: underline;
}
</style>
<title>Calendar</title>
</head>
<body>
<%
Function FixNull(v)
if isNull(v) then
FixNull = ""
Else
FixNull = v
End If
End Function
Function NameFromMonth(iMonth)
select case cint(iMonth)
case 1
s = "January"
case 2
s = "February"
case 3
s = "March"
case 4
s = "April"
case 5
s = "May"
case 6
s = "June"
case 7
s = "July"
case 8
s = "August"
case 9
s = "September"
case 10
s = "October"
case 11
s = "November"
case 12
s = "December"
end select
NameFromMonth = s
End Function
Function LastDay(testYear, testMonth)
LastDay = Day(DateSerial(testYear, testMonth + 1, 0))
End Function
Function GetPrevMonth(iThisMonth,iThisYear)
GetPrevMonth=month(dateserial(iThisYear,iThisMonth,1)-1)
End Function
Function GetPrevMonthYear(iThisMonth,iThisYear)
GetPrevMonthYear=Year(dateserial(iThisYear,iThisMonth,1)-1)
End Function
Function GetNextMonth(iThisMonth,iThisYear)
GetNextMonth=month(dateserial(iThisYear,iThisMonth+1,1))
End Function
Function GetNextMonthYear(iThisMonth,iThisYear)
GetNextMonthYear=year(dateserial(iThisYear,iThisMonth+1,1))
End Function
%>
<table border="0" cellpadding="20" cellspacing="0" width="100%" class="box">
<tr>
<td width="100%" align="center">
<table border="1" cellpadding="10" cellspacing="10" width="100%" bordercolor="#DECEB5">
<tr>
<td width="100%">
<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr>
<td width="100%" colspan="3">
<font size='2' FACE='Arial,Helvetica'><B>Instructions: </B>Click on the date to
enquire, unless unavailable</FONT><HR NOSHADE>
</td>
</tr>
<tr>
<td colspan="2" height="50">
<b><font face="Arial" size="2">
Legend</font></b>
</td>
<td rowspan="6" valign="top">
<%
iMonth=Request.QueryString ("Month")
iYear=Request.QueryString ("Year")
iapt=Request.QueryString ("apt")
if trim(iMonth) = "" then iMonth = Month(Now)
sMonth=NameFromMonth(iMonth)
if trim(iYear) = "" then iYear = Year(Now)
Response.Write ("<center><b><font size='3' FACE='Arial,Helvetica'> ")
Response.Write ("<a href='calendar.asp?apt=" & iapt & "&month=" & GetPrevMonth(iMonth,iYear) & "&year=" & GetPrevMonthYear(iMonth,iYear) & "'><<</a>" & " ")
Response.Write ( sMonth & ", " & iYear & " " )
Response.Write ("<a href='calendar.asp?apt=" & iapt & "&month=" & GetNextMonth(iMonth,iYear) & "&year=" & GetNextMonthYear(iMonth,iYear) & "'>>></a><br></b></font><br>")
%>
<table border="0">
<tr>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Sun</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Mon</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Tue</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Wed</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Thu</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Fri</b></font></td>
<td width="40" bgcolor="#DECEB5" height="25"><font face ="century gothic" color="#000000"><b>Sat</b></font></td>
</tr>
<%
set conn = Server.CreateObject("ADODB.Connection")
set cmd = Server.CreateObject("ADODB.Command")
set rs = Server.CreateObject("ADODB.Recordset")
'conn.mode = 3
conn.open strconn
set cmd.activeconnection = conn
i = 0
iLastDay = LastDay(iYear, iMonth)
iFirstDay= Weekday(CDate(imonth & "/01/" & iYear))
iLastDay = iFirstDay + iLastDay - 1
do while i<= iLastDay
if i <> iLastDay then
Response.Write ("<tr>")
else
exit do
end if
for j=1 to 7
if (j < iFirstDay and i = 0) or (i + j > iLastDay) then
Response.Write ("<td width='40' height='25' valign='top' bgcolor='#c0c0c0' NOWRAP></td>")
else
k = k + 1
sDate = "#" & imonth & "/" & k & "/" & iYear & "#"
set rs = conn.execute("SELECT * FROM booking WHERE " & sDate & " >= adate AND " & sDate & " <= bdate")
if rs.eof then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
else
if Request.QueryString("apt") = "college" then
if rs("confirmed")=True and rs("college")=-1 then
slink = ""
sbgcolor = "#981001"
sfont = "#ffffff"
sclass = ""
end if
if rs("confirmed")=false and rs("college")=-1 then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = "#40775F"
sfont = ""
sclass = "box3"
end if
if rs("college")=false then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
end if
elseif Request.QueryString("apt") = "custom" then
if rs("confirmed")=True and rs("custom")=-1 then
slink = ""
sbgcolor = "#981001"
sfont = "#ffffff"
sclass = ""
end if
if rs("confirmed")=false and rs("custom")=-1 then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = "#40775F"
sfont = ""
sclass = "box3"
end if
if rs("custom")=false then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
end if
elseif Request.QueryString("apt") = "herb" then
if rs("confirmed")=True and rs("herb")=-1 then
slink = ""
sbgcolor = "#981001"
sfont = "#ffffff"
sclass = ""
end if
if rs("confirmed")=false and rs("herb")=-1 then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = "#40775F"
sfont = ""
sclass = "box3"
end if
if rs("herb")=false then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
end if
elseif Request.QueryString("apt") = "ball" then
if rs("confirmed")=True and rs("ball")=-1 then
slink = ""
sbgcolor = "#981001"
sfont = "#ffffff"
sclass = ""
end if
if rs("confirmed")=false and rs("ball")=-1 then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = "#40775F"
sfont = ""
sclass = "box3"
end if
if rs("ball")=false then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
end if
elseif Request.QueryString("apt") = "ifsc" then
if rs("confirmed")=True and rs("ifsc")=-1 then
slink = ""
sbgcolor = "#981001"
sfont = "#ffffff"
sclass = ""
end if
if rs("confirmed")=false and rs("ifsc")=-1 then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = "#40775F"
sfont = ""
sclass = "box3"
end if
if rs("ifsc")=false then
slink = "<A HREF = 'booking.asp?month=" & iMonth & "&Day=" & k & "&Year=" & iYear & "'target='_blank'>"
sbgcolor = ""
sfont = ""
sclass = "box"
end if
end if
end if
Response.Write ("<td width='40' height='25' valign='top' bgcolor='" & sbgcolor & "' class='" & sclass & "'><font face='century gothic' size='3' color='" & sfont & "'>")
Response.Write "<B> "
Response.Write slink
Response.write k & "</A></B>" & sEvent
Response.Write ("</td>")
end if
next
i=i+7
loop
Response.Write ("</tr>")
%>
<%
if rs.state <> 0 then rs.close
set rs = nothing
set cmd = nothing
conn.close
set conn = nothing
%>
</table>
-----------------------------