Calendar source Program

Source: Internet
Author: User
Tags date days in month valid
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>
&LT;TD bgcolor= #000099 align= "center" colspan=7>
<table width=100% border=0 cellspacing=0 cellpadding=0>
<TR>
&LT;TD align= "right" ><a href= "./calendar.asp?date=<%=
Subtractonemonth (ddate)%> "><font color= #FFFF00 size="-1 "><<</FONT></A></TD>
&LT;TD align= "center" ><font color= #FFFF00 >



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.