View Single Post
  #8   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 06:18:01 -0700, Firoz Khan
wrote:

Hi Jacob,
thanks for your reply
it seems my qstn was not clear enough
is it possible to get the result as below ?

Date In Date Out Jan Feb Mar
9-Jan-09 16-Mar-09 22 29 15
where Date In and Date Out is input data and Jan, Feb and Mar are results
is there any formula to get the days of every month for a given period of
time ?
regards
Firoz


Some minor changes should be made in my formula depending on how you want to
count.

For example, in your example, you are apparently not counting either the first
or the last day of the interval.

Is that what you want?

The formula I first proposed doesn't count the first day (day_in) but does
count the last day.

If you want to include BOTH the first and last day of the interval in your
count, then, with the same setup as before, try:

C2:
=IF($B2$A2,SUMPRODUCT(--(MONTH(ROW(INDIRECT($A2&":"&$B2)))=MONTH(C$1))),"" )

Fill right to N2 and down as far as required.

If you don't want to count either the Date_In or Date_Out (or both), merely add
1 to Date_In, or subtract 1 from Date_out, as appropriate.

e.g. -- to not count first but count last (similar to what you posted):
=IF($B2$A2,SUMPRODUCT(--(MONTH(ROW(INDIRECT($A2+1&":"&$B2)))=MONTH(C$1))), "")


--ron