Here is the code I have so far.
This is a Calendar Plugin that I have set up to find the difference between the two dates. The Idea is to select the first date as the day an employee left work, and have the second date as the date the employee returns to work. I am trying to figure out how to get the right amount of days, with the weekends being factored out. At the moment, if you leave on a monday and return on a monday, you are gone for 7 days. I need this to only be 5 days.
Here is a line of code that someone previously suggested:
This code looks like it could be useful, but my knowledge of how to implement it into my program is very limited. Perhaps there is an easier way to acomplish this? Could I use some simple math to take away 2 days from every 7 that are found with my DateDiff?
Any help is most appreciated.
Thank you
Code:
Private Sub Command17_Click()
Dim intHours As Double
Dim intTrial As Double
Me.DaysGone = DateDiff("d", [LeaveDate], [ReturnDate])
intHours = DaysGone * 8
HoursGone = intHours
End Sub
Here is a line of code that someone previously suggested:
Code:
'MoveWD moves datThis on by the intInc weekdays.
Public Function MoveWD(datThis As Date, intInc As Integer) As Date
MoveWD = datThis
For intInc = intInc To Sgn(intInc) Step -Sgn(intInc)
MoveWD = MoveWD + Sgn(intInc)
Do While (Weekday(MoveWD) Mod 7) < 2
MoveWD = MoveWD + Sgn(intInc)
Loop
Next intInc
End Function
Any help is most appreciated.
Thank you
Comment