# Thread: Count number of days in a Month

1. Registered User
Join Date
Sep 2004
Posts
17

## Unanswered: Count number of days in a Month

Is there a way to count the number of days in a particular month?

2. Registered User
Join Date
Sep 2004
Posts
161
If i remember
Datdiff("d", "01/01/04","31/01/04")

3. Grand Poobah
Join Date
Sep 2003
Location
MI
Posts
3,713
Originally Posted by treddinger
Is there a way to count the number of days in a particular month?
Why would you even want to bother? Except for Feb, each month has a fixed # of days ... Use an enum.

4. Purveyor of Discontent
Join Date
Mar 2003
Location
The Bottom of The Barrel
Posts
6,102
I have no clue why you would want to do this...

DatePart("d", DateAdd("d", -1, Month(YourDate) + 1 & "/1/" & Year(YourDate)))
Last edited by Teddy; 11-17-04 at 17:37.

5. Registered User
Join Date
Oct 2003
Location
Ger
Posts
1,969
Here is a function that does the job:
PHP Code:
```   Function MonthDays(anyMonth As Byte) As Integer     Dim anyDate As Date     Dim nDays As Integer     'Adding one month to the given date then     'calculate the Difference between the two dates          anyDate = DateSerial(Year(date), anyMonth, 1)     nDays   = DateSerial(Year(anyDate), Month(anyDate) + 1, Day(anyDate)) _                - DateSerial(Year(anyDate), Month(anyDate), Day(anyDate))     MonthDays= nDays  ```
This will compute the days of the given month for the current year.
You can modify it to get the number of days of any month in any year.

6. Registered User
Join Date
Oct 2003
Location
Ger
Posts
1,969