Calculating Time Fields
I have a timesheet application that uses ms access as the db and I am having problems calculating the total time in the fields I used to capture the time they punched in.
these are the fields (time fields in access, no date)
TimeIn, TimeOut, LunchBeg, LunchEnd
How do I sum up the total amount of hours and minutes and put them into TotalTime (another field). Thanks.
This is what i've been trying:
mySQL_AT = "Select DateDiff('n', TimeIn, LunchBeg) As Tin, DateDiff('n', LunchEnd, TimeOut) As Tout From Emp_Hrs_Worked " _
& "Where workdate = #" & Date & "# And Socsec = '" & Session("frmUserid") & "'"
set rsAT = conntemp.Execute(mySQL_AT)
TT = rsAT("Tin") + rsAT("Tout")
[769 byte] By [
abenitez77] at [2007-11-11 7:54:15]

# 1 Re: Calculating Time Fields
I would store TotalTime as an Integer, the number of minutes worked that day. You can use the following query to update the TotalTime column:
UPDATE HoursWorked SET TotalTime = DateDiff("n", TimeIn, LunchBeg) + DateDiff("n", LunchEnd, TimeOut);
To display TotalTime as hours and minutes, use this:
SELECT Format(TotalTime / 1440, "Short Time") AS TimeWorked
FROM HoursWorked;