View Single Post
  #2  
Old March 29th, 2010, 08:29 PM posted to microsoft.public.excel.newusers
Joe User[_2_]
external usenet poster
 
Posts: 757
Default Number of days falling in various years

"Revenue" wrote:
The first is 6/20/02 and the second is 1/15/2006.
I need to calculate in separate columns for years
2001 through 2006 the number of day in this year
that are between these two dates.


First, I calculate a total of 1306 days, namely: DATE(2006,15,1) -
DATE(2002,6,20) + 1 (formatted as General).

If you agree with that method of counting, and if the start and end dates
are in J2 and K2 respectively, and the years 2001 through 2006 as in O1:O6,
then put the following formula into O1, format as General if necessary, and
copy down through O6:

=MAX(0, MIN(DATE(O1,12,31),$K$2) - MAX(DATE(O1,1,1),$J$2) + 1)


----- original message -----

"Revenue" wrote in message
...
I am starting two dates in my example. The first is 6/20/02 and the
second is 1/15/2006. I need to calculate in separate columns for years
2001 through 2006 the number of day in this year that are between
these two dates. For example, in 2001, the answer is -, in 2002, the
answer is 194, and in years 2003 through 2005, the answer is 365, and
finally in 2006, the answer is 15 days.


The formula below almost works, but 2001 it came up with a negative
number.

=MIN(IF(DATE(O1,12,31)$K$2,0,MIN((DATE(O1,12,31)-$K$2),
365)),IF(DATE(O1,12,31)$J$2,MIN((DATE(O1,12,31)-$K$2),365),G2-
DATE(O1,1,1)+1))

Surely there is a function to handle this sort of thing.

Thanks,


Bruce