Calculating start dates for last 52 weeks

# Thread: Calculating start dates for last 52 weeks

1. Rittu Rasouli Guest

## Calculating start dates for last 52 weeks

I want to create a drop-down list which dynamically creates the start dates for the last 52 weeks, each week beginning the Monday. For example, August 16, 1999, Aug 9, 1999, Aug 02, 1999 etc. Can someone point me to code that calculates the dates?<BR><BR>Thanks in advance,<BR><BR>Rittu.

2. Junior Member
Join Date
Dec 1969
Posts
10

## RE: Calculating start dates for last 52 weeks

there maybe a way slicker way then this, and this is from the top of my head and its early in the morning so syntex might not all be there 100%<BR><BR>but while building your drop down you could do a loop where u use the dateSerial comand and take the first Monday of the 52 week cycle and then add 7 days to it each time.... ie<BR>if fist monday was 1-5-99 then<BR>&#060;%<BR><BR>ndaycount = 5<BR><BR>for i = 1 to 52 <BR> %&#062;<BR>&#060;select&#062;&#060;%=dateserial(19 99,1,ndaycount)%&#062;&#060;/SELECT&#062;<BR>&#060;% ndaycount = ndaycount + 7 <BR>next %&#062;<BR><BR>thats a way simplistic version of it, but i think it would work... i have done the same thing just not a full 52 week deal but i have for all in one month and it worked for me.....<BR><BR>best of luck<BR>~aaron T.<BR>

3. Rittu Guest

## RE: Calculating start dates for last 52 weeks

Hi,<BR><BR>Thanks for your help. However, how would you keep track of months that have 30 days or 31 days and leap years etc.?<BR><BR>

4. Junior Member
Join Date
Dec 1969
Posts
10

## RE: Calculating start dates for last 52 weeks

well its defenetly something u want to test, but the dateserial is a internal function that i think will take care of all that, ie if you put in june for the month and add 35 days it will know that june has XX amount of days and then take the remander and add it to july... .leap year!?!? now that i cant answer, tho each of these would be easy to verify by running tests.<BR>best of luck!<BR>~Deion

#### Posting Permissions

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