Results 1 to 2 of 2
  1. #1
    Join Date
    Jul 2006
    Posts
    157

    Unanswered: How to i count all Mon, Tues,Wed, Thu, Fri in the current month

    Hi: Can any one please tell me how to i count total Monday, Tuesday, Wednesday, Thursday, Friday in the current month. For
    example February has total 4 Mondays, total 4 Tuesdays, total 4 Wednesday, total 4 Thursday and total 4 Fridays. So the total is 20 means exclude the Saturday and Sunday. Also the Current is 6. 6 means if i count total days and exclude Saturday and Sunday then the current shows 6. How to i calculate that needs help.

    Thanks

  2. #2
    Join Date
    Jul 2003
    Location
    Michigan
    Posts
    1,941
    I have a function that does that....
    You'll need to clean it up to fit your needs, but it should give you an idea.

    I pass it a date, and it returns how many workdays are in the month for that date. Note that I call another function (IsHoliday)that weeds out the paid holidays that my company takes.


    Code:
    Function CountWorkDays_Total(dtmDate) As Byte
      Dim bCntDay As Byte, dtmTemp As Date, bDaysInMnth As Byte, bLastDay As Byte, dtmFirstDay, intCntWDay As Integer
      bLastDay = DatePart("d", DateAdd("d", -1, CDate(DatePart("m", DateAdd("m", 1, dtmDate)) & "/1/" & DatePart("yyyy", DateAdd("m", 1, dtmDate)))))
      dtmFirstDay = DateAdd("m", -1, CDate(DatePart("m", DateAdd("m", 1, dtmDate)) & "/1/" & DatePart("yyyy", DateAdd("m", 1, dtmDate))))
      intCntWDay = 0
      For bCntDay = 0 To bLastDay - 1
        dtmTemp = DateAdd("d", bCntDay, dtmFirstDay)
        Select Case DatePart("w", dtmTemp)
          Case vbSunday, vbSaturday
            'make sure Xmas or New Years don't fall in the weekend
            If DatePart("m", dtmTemp) = 1 And DatePart("d", dtmTemp) = 1 Then
              intCntWDay = intCntWDay - 1
            End If
            If DatePart("m", dtmTemp) = 12 And DatePart("d", dtmTemp) = 25 Then
              intCntWDay = intCntWDay - 1
            End If
          Case Else
            If Not IsHoliday(dtmTemp) Then
              intCntWDay = intCntWDay + 1
            End If
        End Select
      Next bCntDay
      CountWorkDays_Total = intCntWDay
    End Function
    Inspiration Through Fermentation

Posting Permissions

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