Last and next year the same as current year?!?!

# Thread: Last and next year the same as current year?!?!

1. Member
Join Date
Dec 1969
Posts
51

## Last and next year the same as current year?!?!

Hello,<BR><BR>Why is that when I hit the last or next button enough times that it comes in the year before or the year after that the dates are going back to the current year??? Look at my script please:<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>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> 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;&#060;%= "Week number: " & CurrentWeek %&#062;&#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;/tr&#062; <BR> &#060;tr&#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

## That code doesn't...

...say anything about a year.<BR><BR>You are requesting the number of the week. So, the first week in January is 1 (or 0, I dunno). The last one is 51 (or 52).<BR><BR>When it moves past the lower bound (going down), or past the upper bound (going up), then the VBScript parser will automatically wrap back to the correct week.<BR><BR>However, it&#039;s not going to take into account the fact that the YEAR has gone backwards or forwards, because you&#039;ve not asked it for that!<BR><BR>Craig.

3. Member
Join Date
Dec 1969
Posts
51

## RE: That code doesn't...

Yes your right! But do you (maybe) know how I can do that!????<BR><BR>

4. Senior Member
Join Date
Dec 1969
Posts
497

## maybe if...

#### Posting Permissions

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