View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Biff Biff is offline
external usenet poster
 
Posts: 1,688
Default Breaking down days between dates

Here's another one:

A2 = start date = 11/7/2004
B2 = end date = 1/16/2005

D1 = header = Month/Year
E1 = header = Days

Formula in D2:

=IF(DATE(YEAR(A$2),MONTH(A$2)+ROWS($1:1)-1,1)<B$2,TEXT(DATE(YEAR(A$2),MONTH(A$2)+ROWS($1:1)-1,1),"mmmm
yyyy"),"")

Formula in E2:

=IF(MAX(A$2,DATE(YEAR(A$2),MONTH(A$2)+ROWS($1:1)-1,1))<B$2,MIN(DATE(YEAR(A$2),MONTH(A$2)+ROWS($1:2)-1,0),B$2)-MAX(A$2,DATE(YEAR(A$2),MONTH(A$2)+ROWS($1:1)-1,1))+1,"")

Select both D2 and E2 and copy down until you get blanks. The output will
look like this:

......................D......................E
1...........Month/Year............Days
2...........November 2004.......24
3...........December 2004.......31
4...........January 2005...........16
5..............................................

Biff

"Veritec" wrote in message
...
Given two dates (e.g. November 7, 2004 and January 16, 2005) I am trying
to
identify how many days are in November, December, and January.

The dates represent meter readings and I am trying to breakdown how much
of
the overall consumption can be assigned to each individual month. In the
example above 7 days in November, 31 in December, and 16 in January.

Thanks for your help.