Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calendar file problem

Status
Not open for further replies.

millerspac

Instructor
Nov 28, 2001
1
GB
Hi

We've been running an ICT Room booking system on our school Intranet for the past year using IIS 4 and Win NT. We've just upgraded our network to Win 2K and IIS 5, and there's a whole load of problems!!!!

At first the Calendar wasn't displaying the full month - we discovered that a function used to calculate the last day in the given month was returning the Month value, and not the Date. So we fixed that!... then we found that links from the calendar to our view page weren't working properly - Only mon to fri are supposed to link, however it seems fairly random in deciding which days to link and which not to.

It's also supposed to send the date through to the through page - EG - the link is supposed to be "view.asp?date=14/08/02" However, it's outputting some dates incorrectly - EG - "view.asp?date=08/14/02".

Any ideas whats going wrong??? I'm a newbie, so please try and keep it in simple terms! :eek:) Thanks

I've included the asp code as it currently is in here - as you can see we didn't originally write it!!!

****************************************************
<!-- #INCLUDE FILE = &quot;custom.asp&quot; -->
<!-- #INCLUDE FILE = &quot;adovbs.inc&quot; -->
<%
' Name: ASP Calendar
' Author: Manohar Kamath
' Version: 1.0
' Copyright Manohar Kamath. Original calendar copyright Wrox Press
' Adapted by F Dundas, Orinoco Software

'--------------------------------------------------
' This function finds the last date of the given month
'--------------------------------------------------
Function GetLastDay(intMonthNum, intYearNum)
Dim dNextStart
If CInt(intMonthNum) = 12 Then
dNextStart = CDate( &quot;1/1/&quot; & intYearNum )
Else
dNextStart = CDate( intMonthNum + 1 & &quot;/1&quot; & &quot;/&quot; & intYearNum)
End If

GetLastDay = Day(dNextStart - 1)


End Function



'--------------------------------------------------
' This routine prints the individual table divisions for days of the month
'--------------------------------------------------
Sub Write_TD(sValue,sClass)

Response.Write &quot; <TD ALIGN='CENTER' WIDTH=20 HEIGHT=15 VALIGN='BOTTOM' CLASS='&quot; & sClass & &quot;' > &quot; & sValue & &quot;</TD>&quot; & vbCrLf
End Sub


' Constants for the days of the week
Const cSUN = 1, cMON = 2, cTUE = 3, cWED = 4, cTHU = 5, cFRI = 6, cSAT = 7

' Get the name of this file
sScript = Request.ServerVariables(&quot;SCRIPT_NAME&quot;)

' Check for valid month input
If IsEmpty(Request(&quot;MONTH&quot;)) OR NOT IsNumeric(Request(&quot;MONTH&quot;)) Then
datToday = Date()
intThisMonth = Month(datToday)

ElseIf CInt(Request(&quot;MONTH&quot;)) < 1 OR CInt(Request(&quot;MONTH&quot;)) > 12 Then
datToday = Date()
intThisMonth = Month(datToday)
Else
intThisMonth = CInt(Request(&quot;MONTH&quot;))
End If

' Check for valid year input
If IsEmpty(Request(&quot;YEAR&quot;)) OR NOT IsNumeric(Request(&quot;YEAR&quot;)) Then
datToday = Date()
intThisYear = Year(datToday)
Else
intThisYear = CInt(Request(&quot;YEAR&quot;))
End If

strMonthName = MonthName(intThisMonth)
datFirstDay = DateSerial(intThisYear, intThisMonth, 1)
intFirstWeekDay = WeekDay(datFirstDay, vbSunday)
intLastDay = GetLastDay(intThisMonth, intThisYear)


' Get the previous month and year
intPrevMonth = intThisMonth - 1
If intPrevMonth = 0 Then
intPrevMonth = 12
intPrevYear = intThisYear - 1
Else
intPrevYear = intThisYear
End If

' Get the next month and year
intNextMonth = intThisMonth + 1
If intNextMonth > 12 Then
intNextMonth = 1
intNextYear = intThisYear + 1
Else
intNextYear = intThisYear
End If

' Get the last day of previous month. Using this, find the sunday of
' last week of last month
LastMonthDate = GetLastDay(intLastMonth, intPrevYear) - intFirstWeekDay + 2
NextMonthDate = 1

' Initialize the print day to 1
intPrintDay = 1

' These dates are used in the SQL
dFirstDay = &quot;1/&quot; & intThisMonth & &quot;/&quot; & intThisYear
dLastDay = intLastDay & &quot;/&quot; & intThisMonth & &quot;/&quot; & intThisYear




%>

<html>
<head>
<title>Schedule for <% = strMonthName & &quot; &quot; & intThisYear %></title>
</head>
<body>
<LINK REL=&quot;stylesheet&quot; TYPE=&quot;text/css&quot; HREF=&quot;<%= CssFile %>&quot;>
<Table Width=&quot;100%&quot; align=&quot;center&quot; cellspacing=&quot;0&quot; cellpadding=&quot;0&quot;>
<tr>
<td>
<table ALIGN=&quot;CENTER&quot; BORDER=&quot;1&quot; CELLSPACING=&quot;0&quot; CELLPADDING=&quot;2&quot; BGCOLOR=&quot;White&quot; BORDERCOLOR=&quot;#000000&quot;>

<tr><td>
<table WIDTH=&quot;126&quot; BORDER=&quot;0&quot; CELLPADDING=&quot;0&quot; CELLSPACING=&quot;0&quot; BGCOLOR=&quot;#FFFFFF&quot;>
<tr HEIGHT=&quot;18&quot; BGCOLOR=&quot;#000080&quot;>
<td WIDTH=&quot;15&quot; HEIGHT=&quot;18&quot; ALIGN=&quot;LEFT&quot; VALIGN=&quot;MIDDLE&quot;><a HREF=&quot;<% =sScript%>?month=<% =IntPrevMonth %>&year=<% =IntPrevYear %>&quot;><img SRC=&quot;images/prev.gif&quot; WIDTH=&quot;10&quot; HEIGHT=&quot;18&quot; BORDER=&quot;0&quot; ALT=&quot;Previous Month&quot;></a></td>
<td WIDTH=&quot;116&quot; COLSPAN=&quot;5&quot; ALIGN=&quot;CENTER&quot; VALIGN=&quot;MIDDLE&quot; CLASS=&quot;<%= THText1 %>&quot;><% = strMonthName & &quot; &quot; & intThisYear %></td>
<td WIDTH=&quot;15&quot; HEIGHT=&quot;18&quot; ALIGN=&quot;RIGHT&quot; VALIGN=&quot;MIDDLE&quot;><a HREF=&quot;<% =sScript %>?month=<% =IntNextMonth %>&year=<% =IntNextYear %>&quot;><img SRC=&quot;images/next.gif&quot; WIDTH=&quot;10&quot; HEIGHT=&quot;18&quot; BORDER=&quot;0&quot; ALT=&quot;Next Month&quot;></a></td>
</tr>
<tr CLASS=&quot;<%= TBText1 %>&quot;>
<td ALIGN=&quot;CENTER&quot; WIDTH=&quot;18&quot; HEIGHT=&quot;15&quot; VALIGN=&quot;BOTTOM&quot;>S</td>
<td ALIGN=&quot;CENTER&quot; WIDTH=&quot;18&quot; HEIGHT=&quot;15&quot; VALIGN=&quot;BOTTOM&quot;>M</td>
<td ALIGN=&quot;CENTER&quot; WIDTH=&quot;18&quot; HEIGHT=&quot;15&quot; VALIGN=&quot;BOTTOM&quot;>T</td>
<td ALIGN=&quot;CENTER&quot; WIDTH=&quot;18&quot; HEIGHT=&quot;15&quot; VALIGN=&quot;BOTTOM&quot;>W</td>
<td ALIGN=&quot;CENTER&quot; WIDTH=&quot;18&quot; HEIGHT=&quot;15&quot; VALIGN=&quot;BOTTOM&quot;>T</td>
<td ALIGN=&quot;CENTER&quot; WIDTH=&quot;18&quot; HEIGHT=&quot;15&quot; VALIGN=&quot;BOTTOM&quot;>F</td>
<td ALIGN=&quot;CENTER&quot; WIDTH=&quot;18&quot; HEIGHT=&quot;15&quot; VALIGN=&quot;BOTTOM&quot;>S</td>

</tr>
<tr><td HEIGHT=&quot;1&quot; ALIGN=&quot;MIDDLE&quot; COLSPAN=&quot;7&quot;><img SRC=&quot;images/line.gif&quot; HEIGHT=&quot;1&quot; WIDTH=&quot;140&quot; BORDER=&quot;0&quot;></td></tr>
<%
' Initialize the end of rows flag to false
EndRows = False
Response.Write vbCrLf

' Loop until all the rows are exhausted
Do While EndRows = False
' Start a table row
Response.Write &quot; <TR>&quot; & vbCrLf
' This is the loop for the days in the week

For intLoopDay = cSUN To cSAT

' If the first day is not sunday then print the last days of previous month in grayed font
If intFirstWeekDay > cSUN Then
Write_TD LastMonthDate, &quot;TableText2&quot;
LastMonthDate = LastMonthDate + 1
intFirstWeekDay = intFirstWeekDay - 1
' The month starts on a sunday
Else
' If the dates for the month are exhausted, start printing next month's dates
' in grayed font
If intPrintDay > intLastDay Then
Write_TD NextMonthDate, &quot;TableText2&quot;
NextMonthDate = NextMonthDate + 1
EndRows = True
Else
' If last day of the month, flag the end of the row
If intPrintDay = intLastDay Then
EndRows = True
End If

dToday = CDate( intPrintDay & &quot;/&quot; & intThisMonth & &quot;/&quot; & intThisYear)

if (weekday(dToday) = cSun) or (weekday(dToday) = cSat) then
bWeekDay = False
else
bWeekDay = True
end if

' If a weekday then allow link to click, else write normal text
image = &quot;&quot;
if dToday = Date then
Extra1 = &quot;<table height='15' width='18' cellspacing='0' cellpadding='0' bgcolor='#d7d7ff' valign='bottom' class='&quot; & WeekendDayText & &quot;'><tr><td valign='bottom' align='CENTER'>&quot;
Extra2 = &quot;</td></tr></table>&quot;
End if
If bWeekDay = True Then
Write_TD Extra1 & &quot;<A HREF=view.asp?date=&quot;& dToday & &quot; CLASS='&quot;& WeekDayText &&quot;' TARGET='ViewFrame'> &quot; & intPrintDay & &quot;</A>&quot; & Extra2, WeekDayText
else
Write_TD Extra1 & intPrintDay & Extra2,&quot;WeekendDayText&quot;
End If

End If

' Increment the date. Done once in the loop.
intPrintDay = intPrintDay + 1
End If

' Move to the next day in the week

Extra1 = &quot;&quot;
Extra2 = &quot;&quot;
Next

Response.Write &quot; </TR>&quot; & vbCrLf
Loop
%>
</table>
</td></tr>
</table>
</td>
</tr>

</table>

</body>
</html>


 
Hi There ...
I just saw your code and worked on it ...
everything was right except one thing ...
in line 165 you had this code :

dToday = CDate( intPrintDay & &quot;/&quot; & intThisMonth & &quot;/&quot; & intThisYear)
It means the dateformat which you were useing
was &quot;dd/mm/yyyy&quot;

if you just change it to :
dToday = CDate( intThisMonth & &quot;/&quot; & intPrintDay & &quot;/&quot; & intThisYear)

as the &quot;mm/dd/yyyy&quot; date format, everything will work
well.

have fun.
TNX.
E.T.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top