Counting number of days occuring in a week

I need to write a formula to count a number of times a day fall within a week. Let me explain, I have a range of dates: for example, 3rd January to 17 January. Excluding the weekends, I need to know how many days falls in the 1 week, 2nd week etc.

Anyone know how I can do this in the most efficient mannger?

Thanks in advance

Subject: Counting number of days occuring in a week

In LS:

  • Get the starting date

  • Use .AdjustDay(1) until reaching the end date

  • In the cycle, use Weekday(thedate) to increment a counter

  • when the weekday changes from 7 to 1, reset the counter for the next week

Subject: Counting number of days occuring in a week

There is a function called @BusinessDays, but this will only return the number of days in the date range, that are considered to be work days (not in the exclusion list).

Your case is probably a little more tricky. It starts with how you define the beginning of a week …

Subject: RE: Counting number of days occuring in a week

I start with monday ie. since we excluded weekends alread, Monday is day one. I wrote a code halway. Maybe you have ideas…

Subject: Counting number of days occuring in a week

The logic isn’t difficult, but I’d need to know what the output should look like. Where is it going (ie, is this text for a “report”, do you have separate fields for the weeks, do you need a “week beginning…” tag, etc.)?

Subject: RE: Counting number of days occuring in a week

Stan

Thank you for responding. I’d like to put the values in an array. so for example, the task spans over 5 weeks, it might look like this:

3,5,5,5,2

I figured that i could could the business days, determine the number of days in the first week, number of days in the last week then divide the remainder by 5 to get to week total days.

I am concerned if this is efficient at all.