how do i create a query to find records entered within a certain time apart?

C

Christine

Hi there,

Let's say your table name is "MyTable" and you want to
compare against the time in the field
named "Dateentered". The key field for the table
is "MyKey". Create a new query and add "MyTable" to the
query TWICE. You'll see "Mytable" and "MyTable_1" in the
top half the query design view. Add the columns you want
to see from both copies of the table to the query. Now,
add the "dateentered" field from "MyTable" to the query
fields TWICE, both times from the same table. Add "MyKey"
from "MyTable" to the field list.

Now you have to set up your criteria. Under the first
instance of "dateentered", add the following criteria:

<DateAdd("s",20,[MyTable_1].[dateentered])

Under the second instance of "dateentered", add the
following criteria:
=[MyTable_1].[dateentered]

Under the "MyKey" column, add the following criteria:
<> [MyTable_1].[MyKey]

What that does is it compares each record in the table to
every other record. It uses the "dateadd" function to
compare the time of the base record against the time of
the matched record. The criteria on the MyKey column
ensures that the query does not return results where the
source and the target rows are the same row.

That should do it!

This posting is provided "AS IS" with no warranties, and
confers no rights.
 

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

Top