Counting number of weeks in a month.

Results 1 to 2 of 2

Thread: Counting number of weeks in a month.

  1. #1
    Daniel Newman Guest

    Default Counting number of weeks in a month.

    Hi all,<BR><BR>is there a simple way of counting how many weeks (or in my case Mandays) are in a month? I know that sometimes there are four and sometimes there are five, but can we get the server to work this out for us?<BR><BR>Thanks,<BR><BR>Daniel.

  2. #2
    Jason Miller Guest

    Default RE: Counting number of weeks in a month.

    Start with a date of Month/1/Year<BR>Send it to the attached code.<BR>If it returns a month output &#060; month input, don&#039t count it.<BR>Increment returned date by 7<BR>If new month &#062; month input then end else increment mondayCount and loop on the increment by 7.<BR><BR>Code: (by Jason Miller, 1999, cheers!)<BR> function startMonday(strDate)<BR> dim startDate<BR> on error resume next<BR> startDate = cDate(strDate)<BR> if err.number &#060;&#062; 0 then sendError("Error in Monday&#039s Date") else startMonday = dateSerial(year(startDate), month(startDate), day(startDate) - ((weekday(startDate) - 2) + 7))<BR> end function

Posting Permissions

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