Results 1 to 6 of 6
  1. #1
    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. #2
    Join Date
    Sep 2004
    Posts
    161
    If i remember
    Datdiff("d", "01/01/04","31/01/04")
    In code we trust

  3. #3
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713
    Quote 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.
    Back to Access ... ADO is not the way to go for speed ...

  4. #4
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    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.
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  5. #5
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Lightbulb

    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), anyMonth1)
        
    nDays   DateSerial(Year(anyDate), Month(anyDate) + 1Day(anyDate)) _
                   
    DateSerial(Year(anyDate), Month(anyDate), Day(anyDate))
        
    MonthDaysnDays 
    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. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    And here how to call it
    Dim febDays as Integer
    febDays= MonthDays(2)

    Result should be 29 which is the Febraury days in this year 2004

Posting Permissions

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