Results 1 to 3 of 3

Thread: ACCESS97

  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    Charlottetown, Prince Edward Island, Canada
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    ACCESS97

    is there a function that is already defined that calculates the number of days between 2 given dates but excludes the weekends? I see datediff exists but it includes weekend. How about some nasty VB code?
    thanks

    ------------------
    mike

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ACCESS97

    Hi Mike,

    Here's some code I wrote to work around the weekday/weekend issue. It may not be quite as efficient as possible, but it's gotten the job done for me:

    Public Function WeekdaysOnly(StartDate As Date, StopDate As Date) As Integer
    'Written by Mark Johnston, 2000
    Dim Counter As Date 'This checks to see that the days are
    Dim intDays As Integer 'Mon-Fri and counts all but Sat and Sun
    Dim varWeekday As Variant
    intDays = 0
    Counter = StartDate
    Do Until Counter > StopDate
    varWeekday = WeekDay(Counter)
    Select Case varWeekday
    Case 2 To 6
    intDays = intDays + 1
    End Select
    Counter = DateAdd("d", 1, Counter)
    Loop
    WeekdaysOnly = intDays
    End Function

    Enjoy![img]/w3timages/icons/thinks.gif[/img]
    -MarkJ-

  3. #3
    Star Lounger
    Join Date
    Jan 2001
    Location
    Charlottetown, Prince Edward Island, Canada
    Posts
    76
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: ACCESS97

    problem has been resolved. thanks MARKJ!

Posting Permissions

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