Ivan,
....that works too. Now I just got to figure out how they
work
I'll try explaining them to you but remember that I'm biased
Just remember that dates are stored as numbers.
' =========================
Peo's formula builds an array of N dates (N being the number of days between A1
and A2) and verifies for each one if it is a Friday (Weekday =5).
That result is an intermediary array of TRUE/FALSE.
You can change them to 1/0 by applying the -- operator.
SUMPRODUCT sums them up (you could use SUM but it would require you to enter the
formula as an ARRAY formula)
I agree the once you understand the ROW(INDIRECT()) concept to build array of
numbers, this formula seems easier to understand.
' =========================
The formula I provided works on the following principle (for any A2>=A1):
We must get the previous/current Friday to A2 (called PCFA2)
PCFA2 = A2-WEEKDAY(A2-5)+1
If you substract the number of days between PCFA2 and A1, giving nD
For nD 0 to 6 => 1 Friday
For nD 7 to 13=> 2 Fridays
etc.
So:
NFridays = INT(nD /7)+ 1
NFridays = INT(nD /7)+ 7/7
NFridays = INT((nD +7)/7) ' putting the 7 inside
NFridays = INT((PCFA2-A1+7)/7) ' resolving nD => PCFA2-A1
NFridays = INT(( A2-WEEKDAY(A2-5)+1-A1+7)/7) ' resolving PCFA2=>
A2-WEEKDAY(A2-5)+1
NFridays = INT(( A2-WEEKDAY(A2-5)-A1+8)/7) ' simplifying 1+7=8
One thing to remember, even if the dates are separated by many days, this
formula will only invoque ONE call to WEEKDAY(). But I told you I was biased
;-))
Regards,
Daniel M.