View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Héctor Miguel Héctor Miguel is offline
external usenet poster
 
Posts: 434
Default Calculate days in a month

hi, !

I have data in columns as follows:
Start date | End date | April | May | June
What I am trying to get is how many days are in each of the column months.
For instance:
Start date - Jan-4-08 End date: April-2-2008
then a formula that will post 2 in column April , 0 in May and 0 in June
15-April-08 to 9th June 2008 will put 15 , 31 , 9 in respective columns
02-June-08 to 09-July-08 will put 0,0,28


assumptions:

- row1 = titles
April, May & June are "real" date-entries (the last day each month) w/ custom format: "mmm"

- first account in cell [C2] w/ the formula:
=sumproduct(--isnumber(match(row(indirect($a2&":"&$b2)),row(indi rect(date(year(c$1),month(c$1),0)+1&":"&c$1)),0)))

- copy-cross then copy-down

note: first and last matching days are included
- revise your expectations for 15,31,9 (16,31,9) and 0,0,28 (0,0,29)

hth,
hector.