finding date

1. Senior Member
Join Date
Dec 1969
Posts
300

finding date

How to find the first date of the specific week?<BR>for example--how to find the first date of the 25th week of the year?<BR><BR>Thanks!<BR>

2. Senior Member
Join Date
Dec 1969
Posts
11,334

RE: finding date

Well, check the day of the 25th week of the year, and back it up to the previous Monday... at least that&#039;s what I think you&#039;re asking.<BR><BR>Search these forums... I&#039;ve seen the answer to this in here several times.

3. Senior Member
Join Date
Dec 1969
Posts
300

RE: finding date

I am trying to search the forums.<BR>Basically for the 25th week of the year, I should be able to find the date for the first Monday (which is June 14)

4. Senior Member
Join Date
Dec 1969
Posts
2,885

RE: finding date

Your question got me thinking..... I really despise working with dates and it is one of my biggest weaknesses. So, I tried to solve your problem. I wrote this and it does return what you are looking for. However, I did not do any testing beyond that. Let me know if it suits your needs.<BR><BR>[code language="VBScript"]<BR>option explicit<BR>dim dateOut, targetDay, i<BR><BR>i = 0<BR><BR>do while targetDay &#060;&#062; 2 <BR> if i &#060; 2 then<BR> dateOut = (DateSerial(2004, 1, 1) + (24*7)+i)<BR> else<BR> dateOut = (DateSerial(2004, 1, 1) + (24*7)-i)<BR> end if<BR> targetDay = weekDay(dateOut)<BR> i = i + 1<BR>loop<BR><BR>Response.Write(dateOut & " is a Monday.")<BR>[/code]

5. Senior Member
Join Date
Dec 1969
Posts
300

RE: finding date

Thank you very much! <BR><BR>In the mean time in forum I found a function written by Bill Atkinson <BR><BR>Function StartOfWeek( weeknum, yr ) <BR> Dim dt <BR> &#039; as I said, look at DateAdd... <BR> &#039; just add specified number of weeks to Jan 1 of given year <BR> &#039; (we assume that weeknumber 1 means first week of year, so we <BR> &#039; need to add ZERO weeks, etc.) <BR> dt = DateAdd( "ww", weeknum-1, DateSerial( yr, 1, 1 ) ) <BR> &#039; and then I *explicitly* showed you how to do the next step: <BR> StartOfWeek = dt - Weekday(dt, vbMonday) + 1 <BR>End Function <BR><BR>It solved my problem. Thanks again!

6. Senior Member
Join Date
Dec 1969
Posts
2,885

RE: Ok, cool! [eom]

.

Posting Permissions

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