Gaps In Time

M

Mary

Hello!
I am curently calculating the differences in,intime and
outime and totaling that amount. What I would also like to
determine is the gap between the last outime and the next
intime.

Lastoutime - nextintime = gaptime (DateDiff)

I would like to take the value in the last outime and
subtract it from the next intime value to determine the
gap between the last outime and the next intime.

What would be the best way to acconplish this task?

Thanks!
 
A

Allen Browne

A subquery is probably the easiest way to get information from another row
of the same table. Results will be read-only.

This example assumes a table named "MyTable", with a foreign key named
"KeyID". It gives you the most recent outtime before this intime for the
same KeyID. Type this expression (one line) into the Field row of query
design:

Lastoutime: (SELECT Max(outime) FROM MyTable AS Dupe
WHERE (Dupe.KeyID = MyTable.KeyID) AND (Dupe.outime < MyTable.intime))
 

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

Similar Threads

summing time 4
DateDiff question 6
VBA Coding Help for Beginner 0
Need "Div/0" Average Relief ... 4
Displaying time gaps 6
Adding Time 2
month gaps counting through whole column 15
teaching project 0

Top