How to give where condition in the select query?
ACCESS 2003
MY Query
SELECT RECORDNO, PERSONID, EMPNAME, TITLENAME, DEPARTMENT, NATION,
CARDEVENTDATE, INTIME, OUTTIME, (select TOP 1 F1.CARDEVENTDATE from
tmp_cardevent as F1 where F1.RECORDNO < F2.RECORDNO AND F1.PERSONID =
F2.PERSONID order by F1.RECORDNO DESC, F1.PERSONID DESC) AS PrevDate,
(select TOP 1 F1.OUTTIME from tmp_cardevent as F1 where F1.RECORDNO <
F2.RECORDNO AND F1.PERSONID = F2.PERSONID order by F1.RECORDNO DESC,
F1.PERSONID DESC) AS PrevOut FROM tmp_cardevent AS F2
I want to use:
WHERE CARDEVENTDATE BETWEEN '" & sdate & "' AND '" & edate & "'
From the above query how can I give the where condition, I tried this:
SELECT RECORDNO, PERSONID, EMPNAME, TITLENAME, DEPARTMENT, NATION,
CARDEVENTDATE, INTIME, OUTTIME, (select TOP 1 F1.CARDEVENTDATE from
tmp_cardevent as F1 where F1.RECORDNO < F2.RECORDNO AND F1.PERSONID =
F2.PERSONID order by F1.RECORDNO DESC, F1.PERSONID DESC) AS PrevDate,
(select TOP 1 F1.OUTTIME from tmp_cardevent as F1 where F1.RECORDNO <
F2.RECORDNO AND F1.PERSONID = F2.PERSONID order by F1.RECORDNO DESC,
F1.PERSONID DESC) AS PrevOut FROM tmp_cardevent AS F2
WHERE F2.CARDEVENTDATE BETWEEN '" & sdate & "' AND '" & edate & "'
But it showing “DATA TYPE MISMATCH ERROR”
And also I tried:
SELECT RECORDNO, PERSONID, EMPNAME, TITLENAME, DEPARTMENT, NATION,
CARDEVENTDATE, INTIME, OUTTIME, (select TOP 1 F1.CARDEVENTDATE from
tmp_cardevent as F1 where F1.RECORDNO < F2.RECORDNO AND F1.PERSONID =
F2.PERSONID and F2.CARDEVENTDATE BETWEEN '" & sdate & "' AND '" & edate
& "' order by F1.RECORDNO DESC, F1.PERSONID DESC) AS PrevDate, (select
TOP 1 F1.OUTTIME from tmp_cardevent as F1 where F1.RECORDNO <
F2.RECORDNO AND F1.PERSONID = F2.PERSONID order by F1.RECORDNO DESC,
F1.PERSONID DESC) AS PrevOut FROM tmp_cardevent AS F2 WHERE
F2.CARDEVENTDATE BETWEEN '" & sdate & "' AND '" & edate & "'
But it showing same “DATA TYPE MISMATCH ERROR”
Can any one help me please