View Single Post
  #12   Report Post  
Posted to microsoft.public.excel.worksheet.functions
Bob Phillips Bob Phillips is offline
external usenet poster
 
Posts: 10,593
Default If a date range contains a leap year (date)

I can make any claim I like, and the OP signed off on it, so I am happy to
leave it at that,

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my addy)

"joeu2004" wrote in message
...
On Jul 4, 1:29 am, "Bob Phillips" wrote:
That is most odd because I get
TRUE TRUE FALSE FALSE
with both, not what the OP suggested, but more logically sound methinks.


Without knowing the OP's purpose, I don't see how you can make that
claim. I don't see how your result is any more "logically sound" than
what the OP asked for. Frankly, I am suspicious of the OP's motives.
I suspect she doesn't want either result.

Be that as it may, I think the following straight-forward formula,
albeit a mouthful, provides exactly the result that the OP is looking
for, for whatever reason, where B1 and B2 are the start and end dates:

=OR( AND(2=MONTH(DATE(YEAR(B1),2,29)),
B1<=DATE(YEAR(B1),2,29),
DATE(YEAR(B1),2,29)<=B2),
AND(2=MONTH(DATE(YEAR(B2),2,29)),
B1<=DATE(YEAR(B2),2,29),
DATE(YEAR(B2),2,29)<=B2) )

And I'm surprised that Bob did not offer the following alternative:

=(SUMPRODUCT(--(2=MONTH(DATE(YEAR(B1:B2),2,29))),
--(B1<=DATE(YEAR(B1:B2),2,29)),
--(DATE(YEAR(B1:B2),2,29)<=B2)) 0)

Both approaches rely on the OP's assurances that the start and end
dates are within 366 days of each other.

Note to the OP: If you are trying to decide whether to use 365 or 366
as a factor in some computation (e.g. daily interest rate), I don't
believe your simple criterion is sufficient. And if you have some
other reason for trying to decide between 365 and 366, I suggest that
you post your purpose. There might be more tractable ways of
achieving your purpose.


----- original posting -----

On Jul 4, 1:29 am, "Bob Phillips" wrote:
That is most odd because I get

TRUE TRUE FALSE FALSE

with both, not what the OP suggested, but more logically sound methinks.

--
HTH

Bob

(there's no email, no snail mail, but somewhere should be gmail in my
addy)

"Rick Rothstein (MVP - VB)" wrote in
. ..



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


Rick


"Rebecca_SUNY" wrote in message
...
Both of these posts answer the question but Bob's is easier for me to
understand.


"Bob Phillips" wrote:


=AND(MONTH(DATE(YEAR(B3),2,29))=2,DATE(YEAR(B3),2, 29)=B1,DATE(YEAR(B3),2,2*9)<=B3)


--
HTH


Bob


(there's no email, no snail mail, but somewhere should be gmail in my
addy)


"Rebecca_SUNY" wrote in
message
...
I need to identify whether a date range contains a leap year day -
2/29. I
have a start date and end date and leap year True/False indicator


Start Date 01/01/08 01/01/08 03/31/08 06/30/07


End Date 12/31/08 06/30/08 12/31/08 03/01/08


Leap Year? TRUE TRUE FALSE TRUE


I can say that the range must be (will be) less than or equal to
365/366.


Thanks!- Hide quoted text -


- Show quoted text -