Selecting records between two dates
I want to select records between two dates from a table.
StartDate and EndDate are two Dates but the code below does not seem to work. I get an operator/operand type mismatch.
rstChkdisb.Open "select * from mytable where ck_date >= " & StartDate & " And ck_date <= " & EndDate & " ORDER BY ck_no", Cnn2, adOpenStatic, adLockReadOnly
Re: Selecting records between two dates
Quote:
Originally posted by IrelandsOwn
I want to select records between two dates from a table.
StartDate and EndDate are two Dates but the code below does not seem to work. I get an operator/operand type mismatch.
rstChkdisb.Open "select * from mytable where ck_date >= " & StartDate & " And ck_date <= " & EndDate & " ORDER BY ck_no", Cnn2, adOpenStatic, adLockReadOnly
VB Code:
rstChkdisb.Open "SELECT * FROM mytable WHERE ck_date BETWEEN #" & StartDate & "# AND #" & EndDate & "# ORDER BY ck_no", Cnn2, adOpenStatic, adLockReadOnly
Cheers...