View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld Ron Rosenfeld is offline
external usenet poster
 
Posts: 5,651
Default Days Calculation

On Sun, 9 Aug 2009 09:55:15 -0600, "Fred Smith" wrote:

Let's say you have dates in C1 to N1, formatted as mmm so it displays Jan
through Dec.
In C2, enter:
=IF(MONTH(C$1)<MONTH($A2),0,IF(MONTH(C$1)=MONTH($ A2),EOMONTH($A2,0)-$A2,IF(MONTH(C$1)<MONTH($B2),DAY(DATE(YEAR($A2),MO NTH(C$1)+1,0)),IF(MONTH(C$1)=MONTH($B2),DAY($B2),0 ))))
Copy across to N2, and down if appropriate.

By the way the correct answers for your example are 28 days for February and
16 days for March.

Regards,
Fred


IT seems that if A2 and B2 are empty, your formula gives a result of 31 for
Jan.
--ron