I need to calculate in hours how much time has passed since the record was created to the current time. The hard part is that I have to exclude weekends from this.
I have been working on this for quite some time, and I'm just lost. Here is what I still have. Thank you in advance for your help.
Dim MyStartTime As DateTime = "2010-08-09 07:00:00.000"
Dim MyEndTime As DateTime = DateAdd("h", -1, Now())
Dim MyHours As Integer = 0
If Weekday(MyStartTime) > 1 And Weekday(MyStartTime) < 6 Then
MyHours = DateDiff("h", MyStartTime, MyEndTime)
ElseIf Weekday(MyStartTime) = 6 Then
Dim EndTime
date1.Date()
MyHours = DateDiff("h", MyStartTime, MyEndTime)
End If
lblHours1.Text = MyHours
Which algorithm in VB.NET is best suited for this calculation?
source
share