Re: DateTime parameters in ADOQuery




I got a strange problem about the DateTime field in MSAccess.

A field in the Access table defined as DateTime, I have the SQL in ADOQuery
SELECT *
FROM Employee
WHERE (DateHired > :StartRange)
AND (DateHired <= :EndRange)

This is my code:
QryEmployee.Close;
QryEmployee.Parameters.ParamByName(StartRange).Value :=
dtThisMonthStocktakeDate;
QryEmployee.Parameters.ParamByName(EndRange).Value :=
dtNextMonthStocktakeDate;
QryEmployee.Open;
if QryEmployee.Eof then
showmessage('no employee');

I found that it always return no employee.
I also checked that the parameter value I passed are correct, eg
1/03/2007 and 1/06/2007

It should have employee return by checking the tables it has employee in
this range.
What datatype are your parameters and the dtNextMonthStocktakeDate variables?
They should be DateTime datatypes if you are going to use parameters. It
appears you are passing strings with the values you say you see


--
Brian Bushay (TeamB)
Bbushay@xxxxxxxxx
.



Relevant Pages

  • Re: problem in reading DateTime from webservice
    ... DateTime is returned by one of the property of type Employee. ... fails again .. ... Please not that i cant touch webservice code. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: This is driving me crazy
    ... EmpID - Autonumber - Primary key ... StartDate - DateTime ... employee to Emp_Job and left join from Jobsite to Emp_Job. ...
    (microsoft.public.access.queries)
  • Re: Help joining several tables
    ... CREATE TABLE Calendar ... (cal_date DATETIME NOT NULL PRIMARY KEY, ... This will give you the status of each employee for each day in the ...
    (microsoft.public.sqlserver.programming)