Page 1 of 1

Creating a parameter of type date for Access database

Posted: Fri Jul 22, 2011 1:40 pm
by fuhrj
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

Posted: Mon Jul 25, 2011 1:35 am
by Alex K.
Hello,

You can use the following query in designer:

Code: Select all

SELECT * FROM tblCustomer WHERE purchaseDate >= ?
and add the @startDate parameter in datasource.
Please see the sample in attachment.

Thank you.