my $days; # This is set to the number of days in the range. # However you get this, it is just end date - start # date in days. my $firstday; # This is a number (1-7) telling which day of the # week the range starts on. For example, if the first # day is today (Tuesday), then this is set to 2. my @daycounts; # This will be an array with seven elements, each one # holding the number of occurances of that day in the # range for(my $i=1; $i<8; $i++){ if($i<$firstday){ $daycounts[$i]=$days/7; } else { $daycounts[$i]=($days+$firstday-$i)/7; if (($days+$firstday-$i)%7>0) { $daycounts[$i]++; } } }