Query - adding time

S

shikha

Hi,

I have a field in table called login time formatted as short time, which
keeps record of login time into queue.

I am trying to do the query which would add the log in time such as 8:15 +
9:15 + 13:15 = 30:45. I am unable to do that.

any suggestions?
 
R

Rick B

You are confusing "time" and "duration". You are trying to store a duration
in a field and formatting it as a time. Duration is how long something
took. Time is a set point in time.

In your example, you are trying to add "nine fifteen am" to "one fifteen pm"
to some time that does not exist.

To do this, you would need to store the "duration" in a number field, not a
time field. You will have to decide what to store (minutes, seconds. hours,
etc.) then you can add them up. Once you get the result, you can display it
in minutes and seconds, or hours and minutes, etc.
 
O

Ofer Cohen

You can do that using two queries
1. Add up the time using minutes
SELECT Sum(DateDiff("n","00:00:00",[FieldName])) AS TotalMinutes
FROM TableName

2. Use the query above to calculate the minuets into houres

SELECT Int([TotalMinutes]/60) & ":" & Format([TotalMinutes] Mod
Int([TotalMinutes]/60)*60,"00") AS NewFieldName
FROM QueryName
 
J

JethroUK©

not sure what benefit of adding together login times tells you ??

if you need to know how long they have been working - you need:

logout (e.g. 17:30) minus login (e.g. 9:00) = 8 hours 30 mins
 
Top