Creating a parameter of type date for Access database
Posted: Fri Jul 22, 2011 1:40 pm
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.
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.