Forgive me but I have hijacked someone else question from another forum
It defines what I'd like to do
It works in the main exception pt ii & v
The attached Excel sheet should be self-explanatory I hope!
I have a fixed date range, "F" (A3:B3) and a number of variable date ranges ("V") in columns D and E.
I want column F to return the number of days between D and E that fall within range F All 6 possible examples are listed-
(i) V starts and ends before F = 0 days
(ii) V starts before range F and ends within F = some of F (start F - end V)
(iii) V starts before before F and ends after F = all of F
(iv) V starts within F and ends within F = some of F (end V - Start V)
(v) V starts within F and ends after F = some of F (start V - end F +1)
(vi) V starts after F and ends after F = 0 days
I've tried 3 different scenarios, all came up with the same answer
.=MAX(0,MIN(B$3,E3)-MAX(A$3,D3)+1)
.=MAX(MIN($B$3,E3)-MAX(D3,$A$3)+1,0)
.=IF(OR($B$3<D3,$A$3>E3),0,(MIN($B$3,E3)-MAX($A$3,D3)+1))
(I think the latter is possibly my best bet but I'm unable to tweak it the correct way)
All help greatly appreciated
Bookmarks