Hi Rich,
This works (tblT is the table, T is the date/time field, and PK is a
field that identifies the record):
SELECT A.PK, A.T, B.PK, B.T
FROM tblT AS A INNER JOIN tblT AS B
ON (DateDiff("s", A.T, B.T) >0)
AND (DateDiff("s", A.T, B.T) <=20);
but the need to compare every record with every other mean multitudinous
calls to DateDiff() which make it excruciatingly slow except with a very
small data set. Cutting out DateDiff() makes it faster though more
opaque:
SELECT A.PK, A.T, B.PK, B.T
FROM tblT AS A INNER JOIN tblT AS B
ON (A.T < B.T)
AND (B.T - A.T < 2.31481481481481E-04);
The constant in the last line is the decimal equivalent of 20 seconds in
an Access date/time field. This syntax also works:
SELECT A.PK, A.T, B.PK, B.T
FROM tblT AS A, tblT AS B
WHERE (A.T < B.T)
AND (B.T - A.T < 2.31481481481481E-04);
I don't know which is faster.
how do i create a query to find records entered within a
certain time apart?
example: 1 of the fields in the datebase captures the
date/time a record was entered. i need to identify any
records that were entered into the database under 20
seconds apart?
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.