Posted to microsoft.public.excel.misc
|
|
Determining a leap year
Caveat - don't try to use years before 1901.
Pete
On Jun 30, 11:00*am, "Rick Rothstein \(MVP - VB\)"
wrote:
And, generalizing this, here is the formula that returns TRUE if a given
year is a leap year...
=ISNUMBER(--(A1&"-02-29"))
where A1 contains a year value (2000, 2007, 2008, etc.). If A1 contains a
date, then that date is in a leap year if this formula returns TRUE...
=ISNUMBER(--(YEAR(A1)&"-02-29"))
Rick
"Rick Rothstein (MVP - VB)" wrote in
. ..
Actually, I take that back... at one function call less, I think this one
is more efficient...
=365+ISNUMBER(--(YEAR(TODAY())&"-02-29"))
Rick
"Rick Rothstein (MVP - VB)" wrote in
l...
But won't something like:
=365+(MONTH(DATE(YEAR(TODAY()),2,28)+1)=2)
do just as well?
I came up with a similar idea, just expressed differently...
=365+ISNUMBER(MONTH(--(YEAR(TODAY())&"-02-29")))
Same number of function calls, but yours avoids the concatenation, so I'm
guessing yours is more efficient.
Rick- Hide quoted text -
- Show quoted text -
|