Search Tools Links Login

Simple ASP Calender


Simple ASP Calender

Original Author: Bhushan-

Code

<%@ Language=VBScript %>
<%
'Function to Return the number of Days in a month
function findMonth(strDate, strYear)
dim days
if strDate = 4 or strDate = 6 or strDate = 9 or strDate = 11 then
days = 30
elseif strDate = 2 AND strYear/4 = int(strYear/4) then
days = 29
elseif strDate = 2 then
days = 28
else
days = 31
end if
findMonth = days
end function
'Function will return the numeric value last or Next Month
function fnChangeMonth(strMonth, strDirection)
if strDirection = "previous" then
if strMonth = 1 then
tempstrMonth = 12
else
tempstrMonth = strMonth - 1
end if
else
if strMonth > 11 then
tempstrMonth = 1
else
tempstrMonth = strMonth + 1
end if
end if
fnChangeMonth = tempstrMonth
end function
'Function will return a date format from the qstring dd
'I use querystring called dd in this format 01012000 this just makes that
'into a date format
function formatQstring(strQstring)
ddLength = Len(strQstring)
tempYear = Right(strQstring,4)
tempDay = Right(strQstring,6)
tempDay = Left(tempday,2)
tempMonth = Left(strQstring,ddLength - 6)

strQstring = tempMonth & "/" & tempDay & "/" & tempYear
formatQstring = formatdatetime(strQstring,2)
end function
'Find the numeric value of the first day in the month (Monday = 2...)
function formatFirstDay(strFirstDay)
strFirstDay = WeekDay(Left(strFirstDay,2) & "/1/" & Right(strFirstDay,4))
formatFirstDay = strFirstDay
end function
'Make the Hyperlink for Previous or Next Month
function makeLink(strDate, strLinkType)
if strdate = "" then
strdate = Month(DisplayDate) & "01" & Year(DisplayDate)
end if

theLength = len(strdate)
theYear = Right(strdate,4)
theMonth = Left(strdate, theLength-6)

if strLinkType = "previous" then
theMonth = fnChangeMonth((Left(theMonth,2)),"previous")
if theMonth = 12 then
theYear = Right(strDate,4) - 1
else
theYear = Right(strDate,4)
end if
else
theMonth = fnChangeMonth((Left(theMonth,2)),"Next")
if theMonth = 1 then
theYear = Right(strDate,4) + 1
else
theYear = Right(strDate,4)
end if
end if
if len(theMonth) <> 2 then
theMonth = "0" & theMonth
end if

strdate = theMonth & "01" & theYear
makelink = strdate
end function
'Determine if there is a Calendar Request to show a month otherwise show this month
if Request("dd") = "" then
DisplayDate = Date()
ShowYear = Year(Date)
FirstDayofMonth = WeekDay(Month(Date) & "/1/" & ShowYear)
else
ShowYear = Right(Request("dd"),4)
DisplayDate = formatQstring(Request("dd"))
FirstDayofMonth = WeekDay(DisplayDate)
end if
previousMonth = findMonth(fnChangeMonth(Month(DisplayDate),"previous"), ShowYear) - FirstDayofMonth + 1
thisMonth = 0
nextMonth = 0
weekdaynum = 0
DisplayMonth = Month(DisplayDate)
If len(DisplayMonth) <> 2 then
DisplayMonth = "0" & DisplayMonth
end if
DisplayYear = Right((DisplayDate),4)
html = "

" & MonthName(month(DisplayDate), 0) & " " & ShowYear & "
" & vbcr
html = html & "SuMoTuWeThFrSa"
for tablecell = 1 to 42
if weekdaynum = 7 then
weekdaynum = 0
end if
weekdaynum = weekdaynum + 1
inc = inc + 1
if inc < FirstDayofMonth then
previousMonth = previousMonth + 1
html = html & "" & previousMonth & "" & vbcr
elseif thisMonth < findMonth(DisplayMonth, ShowYear) then
thisMonth = thisMonth + 1
html = html & "" & thisMonth & "" & vbcr
else
nextMonth = nextMonth + 1
html = html & "" & nextMonth & "" & vbcr
end if
if tablecell/7 = int(tablecell/7) then
html = html & "" & vbcr
end if
Next
html = html & "Previous   Next"
%>





<%=html%>



About this post

Posted: 2002-06-01
By: ArchiveBot
Viewed: 114 times

Categories

ASP/ HTML

Attachments

No attachments for this post


Loading Comments ...

Comments

No comments have been added for this post.

You must be logged in to make a comment.