ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Discussion (Misc queries) (https://www.excelbanter.com/excel-discussion-misc-queries/)
-   -   IF formula to allow Feb 29th in a leap year (https://www.excelbanter.com/excel-discussion-misc-queries/222074-if-formula-allow-feb-29th-leap-year.html)

Mike M.[_2_]

IF formula to allow Feb 29th in a leap year
 
I know the rule that a leap year has to be divisable by 400 or divisable by 4
& 100 but I can't figure out how to put it in a IF formaula. Can anyone help?

Stefi

IF formula to allow Feb 29th in a leap year
 
This formula decides if a year is leap year or not:
=IF(MONTH(DATE(A15,2,29))=2,"leap","not leap")

Regards,
Stefi

€˛Mike M.€¯ ezt Ć*rta:

I know the rule that a leap year has to be divisable by 400 or divisable by 4
& 100 but I can't figure out how to put it in a IF formaula. Can anyone help?


Ron Rosenfeld

IF formula to allow Feb 29th in a leap year
 
On Tue, 24 Feb 2009 06:18:09 -0800, Mike M.
wrote:

I know the rule that a leap year has to be divisable by 400 or divisable by 4
& 100 but I can't figure out how to put it in a IF formaula. Can anyone help?


Depending on your purpose for doing this, the following might suffice (for
every valid Excel year except 1900):

=IF(DAY(DATE(A1,2,29))=29,"Leap Year","Not Leap Year")
--ron

Stefi

IF formula to allow Feb 29th in a leap year
 
Both I and Ron forgot to mention that A15 or A1 refer to a cell cotaining
year number.
Stefi


€˛Ron Rosenfeld€¯ ezt Ć*rta:

On Tue, 24 Feb 2009 06:18:09 -0800, Mike M.
wrote:

I know the rule that a leap year has to be divisable by 400 or divisable by 4
& 100 but I can't figure out how to put it in a IF formaula. Can anyone help?


Depending on your purpose for doing this, the following might suffice (for
every valid Excel year except 1900):

=IF(DAY(DATE(A1,2,29))=29,"Leap Year","Not Leap Year")
--ron


DILipandey

IF formula to allow Feb 29th in a leap year
 
Hi Mike

Supposing the year is in cell A1, use the following formula:-
=IF(MOD(A1,4)=0,"leap year","Not leap")

If you want to check a date automatically, if that date belongs to a Leap
year or NOT, then try following formula.

=IF(MOD(YEAR(TODAY()),4)=0,"leap year","Not leap")

Let me know if it helps. Thanks.

--
Dilip Kumar Pandey
MBA, BCA, B.Com(Hons.)


New Delhi, India


"Mike M." wrote:

I know the rule that a leap year has to be divisable by 400 or divisable by 4
& 100 but I can't figure out how to put it in a IF formaula. Can anyone help?


Rick Rothstein

IF formula to allow Feb 29th in a leap year
 
Another test to add to the pile...

=IF(ISERR(--("29-Feb-"&B1)),"Not Leap","Leap")

--
Rick (MVP - Excel)


"Mike M." wrote in message
...
I know the rule that a leap year has to be divisable by 400 or divisable by
4
& 100 but I can't figure out how to put it in a IF formaula. Can anyone
help?



joeu2004

IF formula to allow Feb 29th in a leap year
 
On Feb 24, 6:18*am, Mike M. wrote:
I know the rule that a leap year has to be divisable
by 400 or divisable by 4 & 100 but I can't figure out
how to put it in a IF formaula. Can anyone help?


If you are specifically looking for an IF() expression with that logic
(for example, to learn how to nest "OR" and "AND" conditions):

=IF(OR(MOD(A1,400)=0,AND(MOD(A1,100),MOD(A1,4)=0)) ,"leap","")

Alternatively:

=IF((MOD(A1,400)=0)+(MOD(A1,100)<0)*(MOD(A1,4)=0) ,"leap","")

PS: That works just fine for 1900, of course, whereas DATE-based
expressions does not (surprise!).

Fred Smith[_4_]

IF formula to allow Feb 29th in a leap year
 
With your year in A1, the following will be True if it is a leap year, and
False if it's not:
=OR(MOD(A1,400)=0,AND(MOD(A1,4)=0,MOD(A1,100)<0))

It works for years 1900 and prior whereas Excel's date function will not.

Regards,
Fred.

"Mike M." wrote in message
...
I know the rule that a leap year has to be divisable by 400 or divisable by
4
& 100 but I can't figure out how to put it in a IF formaula. Can anyone
help?



David Biddulph[_2_]

IF formula to allow Feb 29th in a leap year
 
No. It doesn't help, Dilip. What does that give for the year 2100, or
2200? Those are NOT leap years.
If you go down that line you'd need something like
=IF(OR(MOD(A1,400)=0,AND(MOD(A1,4)=0,MOD(A1,100)< 0)),"leap year","Not
leap")
--
David Biddulph

"DILipandey" wrote in message
...
Hi Mike

Supposing the year is in cell A1, use the following formula:-
=IF(MOD(A1,4)=0,"leap year","Not leap")

If you want to check a date automatically, if that date belongs to a Leap
year or NOT, then try following formula.

=IF(MOD(YEAR(TODAY()),4)=0,"leap year","Not leap")

Let me know if it helps. Thanks.

--
Dilip Kumar Pandey
MBA, BCA, B.Com(Hons.)


New Delhi, India


"Mike M." wrote:

I know the rule that a leap year has to be divisable by 400 or divisable
by 4
& 100 but I can't figure out how to put it in a IF formaula. Can anyone
help?




Rick Rothstein

IF formula to allow Feb 29th in a leap year
 
Technically, you are right... and I was going to respond the same way as you
did, but changed my mind at the last moment figuring that 2100 and 2200 was
far enough into the future that it probably wouldn't be an issue in 99.99%
of any user's applications.

--
Rick (MVP - Excel)


"David Biddulph" <groups [at] biddulph.org.uk wrote in message
...
No. It doesn't help, Dilip. What does that give for the year 2100, or
2200? Those are NOT leap years.
If you go down that line you'd need something like
=IF(OR(MOD(A1,400)=0,AND(MOD(A1,4)=0,MOD(A1,100)< 0)),"leap year","Not
leap")
--
David Biddulph

"DILipandey" wrote in message
...
Hi Mike

Supposing the year is in cell A1, use the following formula:-
=IF(MOD(A1,4)=0,"leap year","Not leap")

If you want to check a date automatically, if that date belongs to a Leap
year or NOT, then try following formula.

=IF(MOD(YEAR(TODAY()),4)=0,"leap year","Not leap")

Let me know if it helps. Thanks.

--
Dilip Kumar Pandey
MBA, BCA, B.Com(Hons.)


New Delhi, India


"Mike M." wrote:

I know the rule that a leap year has to be divisable by 400 or divisable
by 4
& 100 but I can't figure out how to put it in a IF formaula. Can anyone
help?






All times are GMT +1. The time now is 11:11 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com