You will not be able to do this unless you have a way to tie your tables
together.
Presumably you have a table of clients, with a ClientID primary key. Or
perhaps you just assign a ticket number when the person arrives, and use the
same ticket number when they leave. However you do it, you must have some
way to match the arrival record in one table with the departure record in
the other table--a common ClientID or TicketID number.
Step 1: Create a query that shows the arrival time.
You can do this with the query designer.
When you switch to SQL View (View menu), it will look something like this:
SELECT Arrival.ClientID,
Arrival.ArrivalTime
FROM Arrival;
Step 2: Add a subquery to get the matching departure time.
You will have to type the new bit into SQL View.
It will be something like this:
SELECT Arrival.ClientID,
Arrival.ArrivalTime,
(SELECT Min(Depart.DepartTime) AS MinDepartTime
FROM Depart
WHERE Depart.ClientID = Arrival.ClientID
AND Depart.DepartTime > Arrival.ArrivalTime) AS DepartTime
FROM Arrival;
If subqueries are new, see:
http://allenbrowne.com/subquery-01.html
Step 3: Calculate the difference.
Once you have the subquery returning the correct date time value, use
DateDiff() to calculate the difference in minutes. It will be something like
this:
SELECT Arrival.ClientID,
Arrival.ArrivalTime,
DateDiff("n", Arrival.ArrivalTime,
(SELECT Min(Depart.DepartTime) AS MinDepartTime
FROM Depart
WHERE Depart.ClientID = Arrival.ClientID
AND Depart.DepartTime > Arrival.ArrivalTime)) AS Minutes
FROM Arrival;
In the query, it's best to keep the duration as a number, i.e. in minutes or
seconds, or divide by 60 for hours and fractions of an hour. If you need to
display it as hours:minutes in a report, this article explains how:
http://allenbrowne.com/casu-13.html
im currently making a database that logs time for how long people are
waiting
[quoted text clipped - 5 lines]
about queries in databases so can you type in plain english, thanks in
advance.