View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.worksheet.functions
joeu2004 joeu2004 is offline
external usenet poster
 
Posts: 2,059
Default If a date range contains a leap year (date)

On Jul 3, 12:36*pm, "Rick Rothstein \(MVP - VB\)"
wrote:
Unless I am reading your request incorrectly, I do not get either Kostis nor
Bob's formulas producing the correct results. Where your results are

TRUE * TRUE * FALSE * TRUE

I get both of theirs as returning

TRUE * FALSE * TRUE * FALSE


I agree that Bob's formula appears to be obviously flawed, since it
looks for a leap day only in the end-year.

But Kostis's formula works for me with the OP's examples. And the
logic of the formula seems reasonably sound. It says: if the actual
difference between the dates differs from the difference of those
dates in two adjacent years known not have leap days (1901 and 1902),
there must be a leap day between the actual dates.

I think the only time that logic and formula fail is when the start
and end dates are both on the (same) leap day. But it is unclear what
result the OP would want in that case, since her motives are unclear.