How to calculate total time duration

mifee

Registered User.
Local time
Tomorrow, 04:34
Joined
Jun 19, 2012
Messages
10
hi..

i have tbl workinghours
inside the tbl there are

-staff id
-date
- time in - data/time format : shorttime
- time out - data/time format : shorttime

in query..i already can count the duration..

eg.

time in 8.30 time out 11.30
duration = 03.:00

now.. i want to calculated total duration
and then the total duration i want to convert to day
the formula = totalduration/8
answer = in day

need help for that..

thanks
 
Till someone comes along, just check if below gives some guidelines :
Code:
SELECT 
	myTable.staffid, 
	myTable.TheDate, 
	Sum(DateDiff("h",[timeIn],[timeOut])/8) AS TheTotalDurationDividedBy8
FROM 
	myTable
GROUP BY 
	myTable.staffid, 
	myTable.TheDate;

Thanks
 
here the pic what i want to do..
 

Attachments

  • query.jpg
    query.jpg
    50.6 KB · Views: 643
You should have no trouble achieving that with the DateDiff() function. This article gives one method to achieve this.
 
i have -ve value...(refer attachmenet)

and my query..

Duration: Format([ReplacementLeave]![time in]-1-[ReplacementLeave]![time out],"Short Time")

Minutes: DateDiff("n",[time in],[time out])


how to count total hours..:banghead::banghead: :D:D
 

Attachments

  • query2.jpg
    query2.jpg
    40.3 KB · Views: 325
you can just add times together.

dim totaltime as date
totaltime = dsum(times)

- now the problem is that if you try to view the total time as a time, it will wrap if greater than 24hours, so a totaltime of 26 hours will just show as 2hrs. a total time of 52 hours, will show as 4hours (ie 4 hrs in excess of 48 hours)

- however the REAL total stored in access will be 1 day, 2 hrs, or 2 days, 4hrs in the examples.

- so we can change the time to a real number of hours or minutes, quite easily

elapsedrealhours = totaltime * 24
elapsedrealminutes = totaltime * 24 * 60

hope this idea helps
 

Users who are viewing this thread

Back
Top Bottom