# Thread: days in the month

1. 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. 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. Or you could use:
=DAY(DATE(A1,3,0))

4. [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. [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]

6. 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
•