Calculate time between events

hooks

Registered User.
Local time
Today, 03:48
Joined
Aug 13, 2004
Messages
160
Calculate time between events -- CLOSED

Hello all. I have attached very little sample Access 2000 database with one table and one query. I want the query to give me the time difference between each entry.

Example
Code:
EntryID            EntryTime                 **** This is what i want added  ****
   1           1/1/2000 1:01:01 PM                 
   1           1/1/2000 1:10:00 PM               0 day 0 hr 8 min 59 sec
   1           1/1/2000 3:02:10 PM               0 day 1 hr 51 min 50 sec

Can anyone help me with this?

Thanks Hooks
 

Attachments

Last edited:
SELECT [tEntries].[EntryID], [tEntries].[EntryTime],
IIF(IsNull((Select Max(EntryTime) from tEntries as S where S.EntryID =tEntries.EntryID and S.EntryTime<tEntries.EntryTime)),Null, Int(tEntries.EntryTime-(Select Max(EntryTime) from tEntries as S where S.EntryID =tEntries.EntryID and S.EntryTime<tEntries.EntryTime)) & " day " & Format(tEntries.EntryTime-(Select Max(EntryTime) from tEntries as S where S.EntryID =tEntries.EntryID and S.EntryTime<tEntries.EntryTime),"h \h\r n \m\i\n s \s\e\c")) AS [Time Difference]
FROM tEntries
ORDER BY [tEntries].[EntryID], [tEntries].[EntryTime];


The query with an IIF and correlated subqueries is very inefficient. If the table is large, using VBA to update a Time Difference field in the table is much more efficient.
.
 
Thanks a bunch Jon. That is exactly what i was looking for.
 

Users who are viewing this thread

Back
Top Bottom