When using an Access database via OleDB, how does one create a date parameter?
For example:
SELECT * FROM tblCustomer WHERE purchaseDate >= @startDate
To do this in Access, the query would look like this:
SELECT * FROM tblCustomer WHERE purchaseDate >= #7/1/2011#
Dates are wrapped with the hash tag. If I try to do this in Designer, I get a syntax error.
SELECT * FROM tblCustomer WHERE purchaseDate >= #@startDate#
If I leave the hash tags off, I get the error "Data type mismatch in criteria expression.". The @startDate parameter is set to DBDate.
Creating a parameter of type date for Access database
Creating a parameter of type date for Access database
Hello,
You can use the following query in designer:
and add the @startDate parameter in datasource.
Please see the sample in attachment.
Thank you.
You can use the following query in designer:
Code: Select all
SELECT * FROM tblCustomer WHERE purchaseDate >= ?
Please see the sample in attachment.
Thank you.
- Attachments
-
- 1178.SampleReport.mrt
- (7.77 KiB) Downloaded 211 times