+ Reply to Thread
Results 1 to 12 of 12

How to Know Leap Year?

  1. #1
    Registered User
    Join Date
    04-05-2015
    Location
    Saihat, Saudi Arabia
    MS-Off Ver
    2013
    Posts
    46

    How to Know Leap Year?

    Hi,
    In order to know wither the Gregorian year is leap year or not use the following formula:

    =IF(OR((AND(MOD(YEAR(A2);4)=0;MOD(YEAR(A2);100)<>0));(MOD(YEAR(A2);400)=0));29;28)


    Example:
    in cell A2 write "01/01/2004"
    in cell B2 write =IF(OR((AND(MOD(YEAR(A2);4)=0;MOD(YEAR(A2);100)<>0));(MOD(YEAR(A2);400)=0));29;28)
    Result in B2 29 (there for the year 2004 is Leap year)


    Name:  Leap Year.jpg
Views: 265
Size:  58.6 KB

  2. #2
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How to Know Leap Year?

    This formula will also give you the same result

    =IF(DAY(DATE(YEAR(A2);2;29))=1;28;29)
    Audere est facere

  3. #3
    Forum Expert
    Join Date
    12-11-2011
    Location
    Netherlands
    MS-Off Ver
    office 365
    Posts
    3,293

    Re: How to Know Leap Year?

    These 2 will also work:
    Please Login or Register  to view this content.
    Willem
    English is not my native language sorry for errors
    Please correct me if I'm completely wrong

  4. #4
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How to Know Leap Year?

    Quote Originally Posted by popipipo View Post
    =day(eomonth(date(year(a2);2;1);0))
    I like this one

    ....but perhaps one step further......

    =DAY(DATE(YEAR(A2);3;0))

  5. #5
    Forum Moderator Glenn Kennedy's Avatar
    Join Date
    07-08-2012
    Location
    Digital Nomad... occasionally based in Ireland.
    MS-Off Ver
    O365 (PC) V 2403
    Posts
    44,023

    Re: How to Know Leap Year?

    Isn't that wrong.... 2000 was a leap year, whereas 1900, 2100, 2200, etc are not (round centuries must be divisible by 400)
    Glenn




    None of us get paid for helping you... we do this for fun. So DON'T FORGET to say "Thank You" to all who have freely given some of their time to help YOU.

    Temporary addition of accented to illustrate ongoing problem to the TT: L? fh?ile P?draig sona dhaoibh

  6. #6
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How to Know Leap Year?

    That's right, Glenn

    IMA_Saihat's formula will return 29 for 2000

    The formula is returning 29 if either:

    The year is divisble by 4 but not by 100

    or

    The year is divisible by 400

    Of course 1900 is an odd case - Excel get's that wrong (it thinks 1900 is a leap year), so that's the one year where IMA_Saihat's formula works.....but mine don't
    Last edited by daddylonglegs; 04-05-2015 at 12:24 PM.

  7. #7
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: How to Know Leap Year?

    @DLL

    hmm... Your formula does return 29 from the date 1/1/1900.
    If you like my answer please click on * Add Reputation
    Don't forget to mark threads as "Solved" if your problem has been resolved

    "Nothing is so firmly believed as what we least know."
    --Michel de Montaigne

  8. #8
    Forum Expert daddylonglegs's Avatar
    Join Date
    01-14-2006
    Location
    England
    MS-Off Ver
    2016
    Posts
    14,675

    Re: How to Know Leap Year?

    Quote Originally Posted by AlKey View Post
    hmm... Your formula does return 29 from the date 1/1/1900.
    Yes, but it shouldn't, as Glenn says 1900 and 2100 are not leap years

    IMA_Saihat's formula correctly returns 28 and I notice that popipipo's version with EOMONTH also returns 28

    It's well known that Excel treats 1900 as a leap year, apparently that was done deliberately for compatibility with Lotus 1-2-3 (see here)....but it seems that EOMONTH is out of step with that because EOMONTH in that case is giving 28-Feb-1900 even though 29-02-1900 exists!

  9. #9
    Forum Guru AlKey's Avatar
    Join Date
    07-20-2009
    Location
    Lakeland, FL USA
    MS-Off Ver
    Microsoft Office 2010/ Office 365
    Posts
    8,903

    Re: How to Know Leap Year?

    Thank you DLL and Glenn for clarifying this. The good thing is that we don't have to worry ourselves with the year 2100

  10. #10
    Registered User
    Join Date
    04-05-2015
    Location
    Saihat, Saudi Arabia
    MS-Off Ver
    2013
    Posts
    46

    Re: How to Know Leap Year?

    Hi,
    I changed the formula to show the year (Leap or Normal) instead of 29 or 28 (days of February)
    =IF(OR((AND(MOD(YEAR(A2);4)=0;MOD(YEAR(A2);100)<>0));(MOD(YEAR(A2);400)=0));"Leap Year";"Normal Year")

    Name:  Leap Year 2.jpg
Views: 225
Size:  68.1 KB

  11. #11
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: How to Know Leap Year?

    Quote Originally Posted by daddylonglegs View Post
    It's well known that Excel treats 1900 as a leap year, apparently that was done deliberately for compatibility with Lotus 1-2-3 (see here)....but it seems that EOMONTH is out of step with that because EOMONTH in that case is giving 28-Feb-1900 even though 29-02-1900 exists!
    See http://support.microsoft.com/en-us/kb/214326 (click here) for a more authoritative explanation.

  12. #12
    Forum Expert
    Join Date
    05-01-2014
    Location
    California, US
    MS-Off Ver
    Excel 2010
    Posts
    1,795

    Re: How to Know Leap Year?

    Quote Originally Posted by IMA_Saihat View Post
    I changed the formula to show the year (Leap or Normal) instead of 29 or 28 (days of February)
    =IF(OR((AND(MOD(YEAR(A2);4)=0;MOD(YEAR(A2);100)<>0));(MOD(YEAR(A2);400)=0));"Leap Year";"Normal Year")
    Simpler:
    =IF(AND(DAY(DATE(YEAR(A2);3;0))=29; YEAR(A2)<>1900); "Leap Year"; "Normal Year")
    Last edited by joeu2004; 04-05-2015 at 03:26 PM. Reason: corrected comma-v-semicolon usage

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. How to check if a year in a cell is a leap year
    By Azuko in forum Excel General
    Replies: 2
    Last Post: 01-31-2014, 07:08 AM
  2. How to check if a year in a cell is a leap year
    By Azuko in forum Excel General
    Replies: 1
    Last Post: 01-27-2014, 03:20 AM
  3. Leap year
    By samirz10 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-09-2008, 06:11 PM
  4. Leap year
    By ianma in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 06-03-2008, 03:26 AM
  5. Leap Year
    By realsaggi in forum Excel General
    Replies: 6
    Last Post: 08-27-2007, 01:29 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1