Program | Calendar shows the day, can select a day to display, and can join events.
<%
'*******************************************************
' * ASP Sample code-http://www.asp101.com *
'* *
' * This code was made available as a service to our *
' * Visitors and is provided strictly for the *
' * Purpose of illustration. *
'* *
' * Please direct all inquiries to webmaster@asp101.com *
'*******************************************************
%>
<%
' ***begin Function declaration***
' New and improved getdaysinmonth implementation.
' To Florent Renucci for pointing out of that I
' could easily use the same method I used for the
' Revised Getweekdaymonthstartson function.
Function Getdaysinmonth (Imonth, Iyear)
Dim dtemp
Dtemp = DATEADD ("D",-1, DateSerial (iyear, Imonth + 1, 1))
Getdaysinmonth = Day (dtemp)
End Function
' Previous implementation on Getdaysinmonth
' Function getdaysinmonth (Imonth, Iyear)
' Select case Imonth
' Case 1, 3, 5, 7, 8, 10, 12
' Getdaysinmonth = 31
' Case 4, 6, 9, 11
' Getdaysinmonth = 30
' Case 2
' If IsDate ("February," & Iyear) Then
' Getdaysinmonth = 29
' Else
' Getdaysinmonth = 28
' End If
' End Select
' End Function
Function Getweekdaymonthstartson (Danydayinthemonth)
Dim dtemp
Dtemp = DATEADD ("D",-(Day (Danydayinthemonth)-1), Danydayinthemonth)
Getweekdaymonthstartson = Weekday (dtemp)
End Function
Function Subtractonemonth (ddate)
Subtractonemonth = DateAdd ("M",-1, Ddate)
End Function
Function Addonemonth (ddate)
Addonemonth = DateAdd ("M", 1, Ddate)
End Function
' ***end Function declaration***
Dim ddate ' Date we ' re displaying calendar for
Dim Idim ' Days in Month
Dim Idow ' Day of Week this month starts on
Dim icurrent ' Variable we use to hold current day of month as we write table
Dim iposition ' Variable we use to hold current position in table
' Get selected date. There are two ways to doing this.
' Check if we were passed a full date in RQS (' Date ').
' If ' use it, the if not look for seperate variables, the putting them togeter into a date.
' Lastly check if the date is Valid...if
If IsDate (Request.QueryString ("date")) Then
Ddate = CDate (Request.QueryString ("date"))
Else
If IsDate (Request.QueryString ("month") & "-" & Request.QueryString ("Day") & "-" &
Request.QueryString ("Year")) Then
Ddate = CDate (Request.QueryString ("month") & "-" & Request.QueryString ("Day") & "-"
& Request.QueryString ("Year"))
Else
Ddate = Date ()
' The annoyingly bad solution for those to you running IIS3
If Len (Request.QueryString ("month")) <> 0 or Len (request.querystring ("Day")) <> 0 Or
Len (Request.QueryString ("Year")) <> 0 Or Len (request.querystring ("date")) <> 0 Then
Response.Write "The date you picked is not a valid date. The calendar
is set to today ' s date.<br><br>
End If
' The elegant solution for those of your running IIS4
' If Request.QueryString.Count <> 0 Then Response.Write ' The date you picked is not
A valid date. The calendar is set to today ' s date.<br><br>
End If
End If
' Now we ' ve got the date. Now the choosen month and the "Day of" the week it starts on.
Idim = Getdaysinmonth (Month (Ddate), Year (ddate))
Idow = Getweekdaymonthstartson (ddate)
%>
<!--Outer Table is simply to get the pretty border-->
<table border=10 cellspacing=0 cellpadding=0>
<TR>
<TD>
<table border=1 cellspacing=0 cellpadding=1 bgcolor= #99CCFF >
<TR>
<TD bgcolor= #000099 align= "center" colspan=7>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<TR>
<TD align= "right" ><a href= "./calendar.asp?date=<%=
Subtractonemonth (ddate)%> "><font color= #FFFF00 size="-1 "><<</FONT></A></TD>
<TD align= "center" ><font color= #FFFF00 >