E
Eric
Hello everyone.
How would I go about calculating dates between two dates
if 1 day = 8 hours? Here's my senario.
I have been using this formula to calculate days between
two dates (timestamped):
Function Work_Days(BegDate As Date, EndDate As Date) As
Integer
' Note that this function does not account for holidays.
' From http://mvps.org/access/
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
'Added 7/7/2004 per Sharon Larsen
'Adds the Beginning Date and the End Date on the
Report but omits weekends. (Cycle Time)
BegDate = DateValue(Reports!rptPrintCycleTime!
StartDate)
EndDate = DateValue(Reports!rptPrintCycleTime!
EndDate)
WholeWeeks = DateDiff("w", BegDate, EndDate)
DateCnt = DateAdd("ww", WholeWeeks, BegDate)
EndDays = 0
Do While DateCnt < EndDate
If Format(DateCnt, "ddd") <> "Sun" And _
Format(DateCnt, "ddd") <> "Sat"
Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Work_Days = WholeWeeks * 5 + EndDays
End Function
The code above works great. But now I need it to calculate
hours instead of days. Some of my parameters are that 8am
to 5pm are our working times and 8 hours = 1 day. I would
want to be able to calculate how many hours a user as done
his/her work, based on a 8am to 5pm workday. So for
example, if someone started on 9/15/2004 8:00:00 AM and
finished on 8/16/2004 2:00:00 PM, I would want to show 12
hours.
How would I go about calculating dates between two dates
if 1 day = 8 hours? Here's my senario.
I have been using this formula to calculate days between
two dates (timestamped):
Function Work_Days(BegDate As Date, EndDate As Date) As
Integer
' Note that this function does not account for holidays.
' From http://mvps.org/access/
Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer
'Added 7/7/2004 per Sharon Larsen
'Adds the Beginning Date and the End Date on the
Report but omits weekends. (Cycle Time)
BegDate = DateValue(Reports!rptPrintCycleTime!
StartDate)
EndDate = DateValue(Reports!rptPrintCycleTime!
EndDate)
WholeWeeks = DateDiff("w", BegDate, EndDate)
DateCnt = DateAdd("ww", WholeWeeks, BegDate)
EndDays = 0
Do While DateCnt < EndDate
If Format(DateCnt, "ddd") <> "Sun" And _
Format(DateCnt, "ddd") <> "Sat"
Then
EndDays = EndDays + 1
End If
DateCnt = DateAdd("d", 1, DateCnt)
Loop
Work_Days = WholeWeeks * 5 + EndDays
End Function
The code above works great. But now I need it to calculate
hours instead of days. Some of my parameters are that 8am
to 5pm are our working times and 8 hours = 1 day. I would
want to be able to calculate how many hours a user as done
his/her work, based on a 8am to 5pm workday. So for
example, if someone started on 9/15/2004 8:00:00 AM and
finished on 8/16/2004 2:00:00 PM, I would want to show 12
hours.