• days in the month

    Author
    Topic
    #459300

    I have to verify the number of days in a month for a financial report. I can do so eaily excpet for February. Is there an easy way to verify the number of days in february?
    Any help is appreciated.

    itconc

    Viewing 2 reply threads
    Author
    Replies
    • #1157780

      Let’s say the year is in cell A1.

      An easy formula that’ll work for all years in the range 1901-2099 is

      =28+(MOD(A1,4)=0)

      Or for years in the range 1901-9999:

      =DATE(A1,3,0)-DATE(A1,2,0)

      Excel will format the result of the latter formula as a date, so you must set the number format to General to see the correct number.

    • #1157880

      Or you could use:
      =DAY(DATE(A1,3,0))

      • #1157932

        Or you could use:
        =DAY(DATE(A1,3,0))

        That’s too easy!

        • #1158011

          That’s too easy!

          Just as an aside Rory’s is also “more correct” as you have not taken into account of modulo 100 and 400 for calculation of leap years

          [codebox]Function isLeapYear(dtyear)
          If dtyear Mod 4 = 0 And dtyear Mod 100 0 Or dtyear Mod 400 = 0 Then
          isLeapYear = “True”
          Else
          isLeapYear = “False”
          End If

          End Function[/codebox]

    • #1159122

      Thanks to all of you!

    Viewing 2 reply threads
    Reply To: days in the month

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: