Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sql with params giving wrong result set

Status
Not open for further replies.

yomyom

Programmer
Dec 23, 2002
119
GB
I'm using sql with :startDate and :endDate params to get records from a tTable.
However, I'm getting funny results.
The sql statement is:
select * from "C:\xyz\Accounts.DB" as Accounts
where Accounts.&quot;Type&quot; = 'Credit' And Accounts.&quot;Date&quot; >= :StartDate and Accounts.&quot;Date&quot; <= EndDate

However, the result set returns the same row twice when the date is just 1 day and only 1 record matches the search criteria.
I then tried to set :endDate to ...Accounts.&quot;Date&quot; < :endDate
and the result set was enpty for the same date as above.
Can anyone tell me what I'm doing wrong?
Thanks in advance,
yomyom.
 
try something like this:

SQL.Add('select * from &quot;C:\xyz\Accounts.DB&quot; as Accounts
where Accounts.&quot;Type&quot; = 'Credit' And Accounts.&quot;Date&quot; Between :StartDate AND :EndDate');
SQL.ParamByName('STARTDATE').AsString := StartDateVariable;
SQL.ParamByName('ENDDATE').AsString := EndDateVariable;
SQL.Active := True;

HTH

Leslie
landrews@metrocourt.state.nm.us

There are 10 types of people in the world -
those who understand binary
and
those who don't!
 
When working with dates, you need to be aware of whether you are working with DateTime or Date fields. If the former, then check out the time being stored by looking at your data carefully, otherwise you may get unexpected results.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top