One more bit of info Michel,
I now get a different error message
![Big Grin :D :D](/styles/default/custom/smilies/grin.gif)
ata Type Mismatch In Criteria
Expression.
The query is:
SELECT A.mgrname, A.DateStamp AS ThisDateStamp, B.DateStamp AS
ThatDateStamp, DateDiff("w",A.DateStamp, B.DateStamp) AS GAP
FROM (qryDateStamp AS A LEFT JOIN qryDateStamp AS B ON (A.mgrname =
B.mgrname) AND (A.DateStamp > B.DateStamp)) LEFT JOIN qryDateStamp AS C ON
(A.mgrname = C.mgrname) AND (A.DateStamp > C.DateStamp)
GROUP BY A.mgrname, A.DateStamp, B.DateStamp
HAVING (((First(B.DateStamp))=Max([C].[DateStamp])));
The only difference between this, and the one I emailed on earlier, is the
field DateStamp is "created" in qryDateStamp as a SHORT DATE field,
through
the syntax: CDate(Left([paydate],2) & "-" & Mid([paydate],3,3) & "-" &
Right([paydate],2)). Paydate is a field with the format ddmmmyy (i.e.
03Mar06).
If I run the query as noted below, I get no error message, but you can see
the JOIN statement has a.datestamp = b and c.datestamp vs. a.datestamp > b
and c.datestamp...
SELECT A.mgrname, A.DateStamp AS ThisDateStamp, B.DateStamp AS
ThatDateStamp, DateDiff("w",A.DateStamp, B.DateStamp) AS GAP
FROM (qryDateStamp AS A LEFT JOIN qryDateStamp AS B ON (A.mgrname =
B.mgrname) AND (A.DateStamp = B.DateStamp)) LEFT JOIN qryDateStamp AS C ON
(A.mgrname = C.mgrname) AND (A.DateStamp = C.DateStamp)
GROUP BY A.mgrname, A.DateStamp, B.DateStamp
HAVING (((First(B.DateStamp))=Max([C].[DateStamp])));
Any ideas why I get this error message?
--
David
Michel Walsh said:
Hi,
If the table has fields like:
f1, dateStamp
then
SELECT a.f1, a.dateStamp As thisDateStamp,
b.dateStamp As PreviousDStampForF1,
a.dateStamp-b.dateStamp as Gap
FROM (myTable As a LEFT JOIN myTable As b ON a.f1=b.f1 AND
a.dateStamp>b.dateStamp)
LEFT JOIN myTable As c ON a.f1=c.f1 AND a.dateStamp >
c.dateStamp
GROUP BY a.f1, a.dateStamp, b.dateStamp
HAVING b.dateStamp = MAX(c.dateStamp)
should do.
Hoping it may help,
Vanderghast, Access MVP