CALENDAR by Weeks!!?!!?!

1. Member
Join Date
Dec 1969
Posts
51

## CALENDAR by Weeks!!?!!?!

Hi,<BR><BR>I&#039;m make a calendar that you can watch by weeks (so not by months). And now I have a problem, and that is that when I&#039;m going to the previous or next year the year doesn&#039;t go with the date so he stay&#039;s in the same year, the current year. <BR><BR>Could someone please help me I&#039;ve looked every where but all the calendars on the internet are monthly calendars and not week calendars. <BR><BR>I will paste the code here under, it&#039;s not very much but please take a look and help me. <BR><BR>Thanx a lot!!!!!!!!!!<BR><BR>&#060;%<BR>&#039; To see what is the current week<BR> If Request.Querystring("week") = "" Then <BR> CurrentWeek = DatePart("ww", Date)<BR> Else <BR> CurrentWeek = Request.Querystring("week")<BR> End If <BR><BR>&#039; To + or - a year<BR> If Request.Querystring("jaar") = "" Then<BR> CurrentYear = Year(Date())<BR> Else <BR> CurrentYear = Request.Querystring("jaar")<BR> End If <BR><BR>&#039;To see if it is a leap year<BR>Function IsLeapYear(CurrentYear)<BR> IsLeapYear = (CurrentYear mod 4 = 0) and ((CurrentYear mod 100 &#060;&#062; 0) or (CurrentYear mod 400 = 0))<BR>End Function<BR><BR>&#039;To see how many weeks are in the year<BR>Function WeeksInYear(CurrentYear)<BR> If WeekDay("1/1/" & CurrentYear) = vbThursday then <BR> WeeksInYear = 53<BR> Exit Function <BR> End If<BR> If WeekDay("1/1/" & CurrentYear) = vbWednesDay and IsLeapYear(CurrentYear) then <BR> WeeksInYear = 53<BR> Exit Function <BR> End If<BR> WeeksInYear = 52<BR>End Function<BR><BR>&#039; For the nextweek<BR>Function NextWeek(tCurrentWeek, tCurrentYear)<BR> Dim RetVal<BR> If CInt(tCurrentWeek) = CInt(WeeksInYear(tCurrentYear)) Then<BR> RetVal = "week=1&" & _<BR> "jaar=" & tCurrentYear + 1<BR> Else<BR> RetVal = "week=" & tCurrentWeek + 1 & "&" & _<BR> "jaar=" & tCurrentYear<BR> End if<BR> NextWeek = RetVal<BR>End Function<BR><BR>&#039; For the previous week<BR>Function PreviousWeek(tCurrentWeek, tCurrentYear)<BR> Dim RetVal<BR> If CInt(tCurrentWeek) = 1 Then<BR> RetVal = "week=" & WeeksInYear(tCurrentYear - 1) & "&" & _<BR> "jaar=" & tCurrentYear - 1<BR> Else<BR> RetVal = "week=" & tCurrentWeek - 1 & "&" & _<BR> "jaar=" & tCurrentYear<BR> End if<BR> PreviousWeek = RetVal<BR>End Function<BR><BR>&#039; To write away the day&#039;s of a week<BR>Call WriteWeek (7)<BR><BR>Function WriteWeek(dtDate)<BR> Dim RetVal<BR> iJumpWeeks = CurrentWeek - DatePart("ww",Date())<BR> dtDate = DateAdd("ww",iJumpWeeks,FirstDayOfWeek(Date()))<BR > <BR> For i = 0 to 6<BR> RetVal = RetVal + "&#060;tr&#062;" &_<BR> "&#060;td&#062;" & "<BR>" & dtDate + i & "&#060;/td&#062;" &_<BR> "&#060;/tr&#062;" <BR> Next<BR> WriteWeek = RetVal<BR>End Function <BR><BR>&#039;To see what is the first day of the week<BR>Function FirstDayOfWeek(dt)<BR> Do While WeekDay(dt) &#062; vbSunday<BR> dt = DateAdd("d", -1, dt)<BR> Loop<BR> FirstDayOfWeek = dt<BR>End Function<BR>%&#062; <BR><BR>&#060;table align="center"&#062;<BR> &#060;tr&#062;<BR> &#060;td&#062;Er zitten &#060;%=WeeksInYear(CurrentYear)%&#062; weken in dit jaar&#060;/td&#062;<BR> &#060;/tr&#062;<BR>&#060;/table&#062;<BR><BR>&#060;table align="center"&#062;<BR> &#060;tr&#062; <BR> &#060;td&#062;&#060;a href="test.asp?&#060;%= PreviousWeek(CurrentWeek, CurrentYear) %&#062;"&#062;---&#060;/a&#062;&#060;/div&#062;&#060;/td&#062;<BR> &#060;td&#062;&nbsp;&#060;/td&#062;<BR> &#060;td&#062;Week &#060;%= CurrentWeek & " - " & CurrentYear%&#062;&#060;/td&#062; <BR> &#060;td&#062;&nbsp;&#060;/td&#062;<BR> &#060;td&#062;&#060;a href="test.asp?&#060;%= NextWeek(CurrentWeek, CurrentYear) %&#062;"&#062;+++&#060;/a&#062;&#060;/td&#062; <BR> &#060;/tr&#062;<BR>&#060;/table&#062; <BR><BR>&#060;table align="center"&#062;<BR> &#060;%= WriteWeek(dtDate + i) %&#062;<BR>&#060;/table&#062;<BR><BR>&#060;/body&#062;<BR>&#060;/html&#062;<BR>

2. Senior Member
Join Date
Dec 1969
Posts
1,913

## As I am in a good mood...

I&#039;m having a curry tonight, here is a better version of your code. It&#039;s not perfect, but it is better. With practice you should be able to significantly improve this.<BR><BR>Hope it helps<BR><BR>&#060;% <BR>&#039; To see what is the current week <BR> Session.LCID=2057<BR> If Request.Querystring("FirstDay") = "" Then <BR> FirstDay = FirstDayOfWeek(Date)<BR> CurrentWeek = DatePart("ww", Date) <BR> Else <BR> FirstDay = Request.Querystring("FirstDay")<BR> CurrentWeek = DatePart("ww", FirstDay)<BR> End If<BR> Response.write "firstday=" & FirstDay & "<BR>"<BR> CurrentYear=Year(FirstDay) <BR><BR>&#039;To see if it is a leap year <BR> Function IsLeapYear(CurrentYear) <BR> IsLeapYear = IsDate("29/02/" & CurrentYear) &#039; This is better than your tests<BR> End Function <BR><BR>&#039;To see how many weeks are in the year <BR> Function WeeksInYear(CurrentYear) <BR> WeeksInYear=DatePart("ww","31/12/" & CurrentYear)<BR> End Function <BR><BR>&#039; To write away the day&#039;s of a week <BR> Call WriteWeek () <BR><BR> Function WriteWeek() <BR> For i = 0 to 6 <BR> RetVal = RetVal + "&#060;tr&#062;&#060;td&#062;" & "<BR>" & DateAdd("d",i,FirstDay) & "&#060;/td&#062;&#060;/tr&#062;" <BR> Next <BR> WriteWeek = RetVal <BR> End Function <BR><BR>&#039;To see what is the first day of the week <BR> Function FirstDayOfWeek(dt) <BR> Do While WeekDay(dt) &#062; vbSunday <BR> dt = DateAdd("d", -1, dt) <BR> Loop <BR> FirstDayOfWeek = dt <BR> End Function <BR>%&#062; <BR><BR>&#060;head&#062;<BR>&#060;meta name="GENERATOR" content="Microsoft FrontPage 4.0"&#062;<BR>&#060;meta name="ProgId" content="FrontPage.Editor.Document"&#062;<BR>&#060 ;/head&#062;<BR><BR>&#060;table align="center"&#062;<BR> &#060;tr&#062;<BR> &#060;td&#062;Er zitten &#060;%=WeeksInYear(CurrentYear)%&#062; weken in dit<BR> jaar&#060;/td&#062;<BR> &#060;/tr&#062;<BR>&#060;/table&#062;<BR>&#060;table align="center"&#062;<BR> &#060;tr&#062;<BR> &#060;td&#062;&#060;a href="111.asp?FirstDay=&#060;% =dateadd("d",-7,firstday) %&#062;"&#062;---&#060;/a&#062;&#060;/td&#062;<BR> &#060;td&#062;&#060;/td&#062;<BR> &#060;td&#062;Week &#060;%= CurrentWeek & " - " & CurrentYear%&#062;&#060;/td&#062;<BR> &#060;td&#062;&#060;/td&#062;<BR> &#060;td&#062;&#060;a href="111.asp?firstday=&#060;% =dateadd("d",7,firstday) %&#062;"&#062;+++&#060;/a&#062;&#060;/td&#062;<BR> &#060;/tr&#062;<BR>&#060;/table&#062;<BR>&#060;table align="center"&#062;<BR> &#060;%= WriteWeek() %&#062; <BR>&#060;/table&#062;<BR>

3. Member
Join Date
Dec 1969
Posts
51

## THANX

THANK YOU VERY MUCH! I almost would say I love you.<BR><BR>THANX!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!! x 10000

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•