Leap Year in Excel - Count how many leap years between dates

Поделиться
HTML-код
  • Опубликовано: 12 дек 2024

Комментарии • 9

  • @sheiladillon9022
    @sheiladillon9022 Год назад +3

    Wo, didn't realise next year is a leap year - thanks for the heads up!

  • @charli29879
    @charli29879 Год назад +3

    Very interesting

  • @cindycubbin2932
    @cindycubbin2932 Год назад +2

    Clever!

  • @simoncubbin8395
    @simoncubbin8395 Год назад

    Thanks for this 😁

  • @xltraining3132
    @xltraining3132 Год назад +4

    Can you check to see how many days are in a year?

    • @computertutoring
      @computertutoring  Год назад +1

      Yep you could use: =IF(DATE(YEAR(A2),12,31)-DATE(YEAR(A2),1,1)+1=366,"Leap","")

  • @JohnSmith-ek7jp
    @JohnSmith-ek7jp 7 месяцев назад +1

    I don't think your formula works, between April 30, 2020 and April 30, 2024 there is only one leap year on Feb 29, 2024 however your formula calculates two

    • @computertutoring
      @computertutoring  7 месяцев назад

      You're right! thanks for that. 😅😅 my formula only works if a leap year occurs in the year you're checking. I've added a few logical conditions to solve your issue:
      =SUMPRODUCT(
      (MOD(ROW(INDIRECT(YEAR(A2) & ":" & YEAR(B2))), 4) = 0) *
      (MOD(ROW(INDIRECT(YEAR(A2) & ":" & YEAR(B2))), 100) 0) +
      (MOD(ROW(INDIRECT(YEAR(A2) & ":" & YEAR(B2))), 400) = 0) *
      (DATE(ROW(INDIRECT(YEAR(A2) & ":" & YEAR(B2))), 2, 29) >= A2) *
      (DATE(ROW(INDIRECT(YEAR(A2) & ":" & YEAR(B2))), 2, 29)