Results 1 to 6 of 6
  1. #1
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    Houston, Texas, USA
    Posts
    242
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    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.

  3. #3
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts
    Or you could use:
    =DAY(DATE(A1,3,0))
    Regards,
    Rory

    Microsoft MVP - Excel

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    [quote name='rory' post='772151' date='24-Apr-2009 15:47']Or you could use:
    =DAY(DATE(A1,3,0))[/quote]
    That's too easy!

  5. #5
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post
    [quote name='HansV' post='772181' date='24-Apr-2009 17:47']That's too easy! [/quote]

    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]
    Jerry

  6. #6
    3 Star Lounger
    Join Date
    Oct 2004
    Location
    Houston, Texas, USA
    Posts
    242
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Post

    Thanks to all of you!

Posting Permissions

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