Last and next year is the same as the current year

# Thread: Last and next year is the same as the current year

1. Member
Join Date
Dec 1969
Posts
51

## Last and next year is the same as the current year

Hello, I&#039;ve got a question! How come that my weeks don&#039;t go further in the last and in the next year, and I mean that if you go to the last year (or next) that you go back to the current year. How come??? (see code I included)! And if someone knows howe to make it work properly, don&#039;t be shy and just reply!<BR><BR>&#060;%<BR>Session.LCID = 2057 <BR><BR> If Request.Querystring("week") = "" Then <BR> WeekToAdd = 0<BR> Else <BR> WeekToAdd = Request.Querystring("week") <BR> End If <BR> <BR>CurrentWeek = DatePart("ww",DateAdd("ww",WeekToAdd, Date)) <BR><BR>Call WriteDates (7) <BR><BR><BR>Function WriteDates(ByVal WeekNumber) <BR> iRequestedWeek = CurrentWeek<BR> iCurrentWeek = DatePart("ww",Date())<BR> iJumpWeeks = iRequestedWeek - iCurrentWeek<BR><BR> dtDate = DateAdd("ww",iJumpWeeks,FirstDayOfWeek(Date()))<BR ><BR> For i = 0 to 6 <BR> Response.Write dtDate + i & "<BR>" <BR> NEXT <BR>End Function <BR><BR>Function FirstDayOfWeek(ByVal 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&#062;<BR> &#060;tr&#062;<BR> &#060;td&#062;&nbsp;&#060;/td&#062;<BR> &#060;/tr&#062; <BR> &#060;tr&#062; <BR> &#060;td&#062;&#060;a href="agenda_test.asp?week=&#060;%=(WeekToAdd-1)%&#062;"&#062;last week&#060;/a&#062;&#060;/td&#062;<BR> &#060;td&#062;&nbsp;&#060;/td&#062; <BR> &#060;td&#062;&#060;%= CurrentWeek %&#062;&#060;/td&#062; <BR> &#060;td&#062;&nbsp;&#060;/td&#062;<BR> &#060;td&#062;&#060;a href="agenda_test.asp?week=&#060;%=(WeekToAdd+1)%& #062;"&#062;next week&#060;/a&#062;&#060;/td&#062; <BR> &#060;/tr&#062;<BR>&#060;/table&#062;

2. Senior Member
Join Date
Dec 1969
Posts
16,931

## Repost

I answered this the other week. The WeekToAdd variable takes no account of the current year. You will need some code in there to take account of it.<BR><BR>Craig.

3. Member
Join Date
Dec 1969
Posts
51

## But what kind..

of code I allready tried somethings but it doesn&#039;t work? And I&#039;m soory that I post it again! <BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
16,931

## From what I remember,

Dutch was helping you.<BR><BR>What did he suggest?<BR><BR>What I would do is find out what the previous week number is. If it&#039;s negative or 0 (I don&#039;t know which means "Previous Year"), then pass the WHOLE DATE for the next week, not the week number.<BR><BR>The same applies for the +1 year scenario. If you ADD ON A WEEK TO THE DATE, and then pass the DATE to the next page, you won&#039;t have a problem. Ever.<BR><BR>Craig.

#### Posting Permissions

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