date/time calculations?

V

vanessa

I created 2 date/time fields named fldstarttime and
fldendtime and 2 dates fields
named StartDate and EndDate.
In addition to that I have an unbound field named
txttimedifference that has the following statement
=Format([fldstarttime]-1-[fldendtime],"Short Time"). This
works fine.
Then I have another unbound field that calculates the nr
of days based on the starting date and
the end date. Field is named : nrofworkingdays. I'm using
the following function to calcualte
the nr of days:

Function Work_Days(BegDate As Variant, EndDate As
Variant) As Integer
' Note that this function does not account for holidays.

Dim WholeWeeks As Variant
Dim DateCnt As Variant
Dim EndDays As Integer

BegDate = DateValue(BegDate)

EndDate = DateValue(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

problems: Work_Days returns an integer, what I really
want to do is to have a total of hrs that someone worked.
For example if someone worked 2 days, then the total nr
of hrs should be = 2 * 8 + txttimedifference .
I have tried several solution but to no avail.
Does anyone has an idea on how to get the total nr of
hours?
Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top