 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
Nenad Blagojevic Guest
|
Posted: Tue Nov 18, 2003 3:33 pm Post subject: SQL and date parameters |
|
|
Hi,
How should parameters being used in dbexpress TSQLQuery components?
I have tried like this (Delphi), but it does not work:
var
StartDate, EndDate: TDate;
....
SQL.Add('AND (Invoices.DateTimeStamp BETWEEN :Start AND :End)');
Params.CreateParam(ftTimeStamp,'Start',ptInput).AsSQLTimeStamp :=
DateTimeToSQLTimeStamp(StartDate);
Params.CreateParam(ftTimeStamp,'End',ptInput).AsSQLTimeStamp :=
DateTimeToSQLTimeStamp(EndDate);
....
I badly want to be free of text conversions (done at the current time) if it
is possible. I am sure it is, but how?
--
Best Regards / Med venlig hilsen,
Nenad Blagojevic
[email]n.blagojevic (AT) techotel (DOT) dk[/email]
AK Techotel A/S
Sandager 8
DK 2605 Brøndby
tel +45 3646 1155
dir. +45 3619 2143
|
|
| Back to top |
|
 |
Wayne Niddery [TeamB] Guest
|
Posted: Tue Nov 18, 2003 4:35 pm Post subject: Re: SQL and date parameters |
|
|
Nenad Blagojevic wrote:
| Quote: |
How should parameters being used in dbexpress TSQLQuery components?
I have tried like this (Delphi), but it does not work:
var
StartDate, EndDate: TDate;
...
SQL.Add('AND (Invoices.DateTimeStamp BETWEEN :Start AND :End)');
Params.CreateParam(ftTimeStamp,'Start',ptInput).AsSQLTimeStamp :=
DateTimeToSQLTimeStamp(StartDate);
Params.CreateParam(ftTimeStamp,'End',ptInput).AsSQLTimeStamp :=
DateTimeToSQLTimeStamp(EndDate);
...
I badly want to be free of text conversions (done at the current
time) if it is possible. I am sure it is, but how?
|
You do not need to create the parameters, just assign them. The parameters
are created for you after assigning the SQL text.
ParamByName(Start).AsSQLTimeStamp := DateTimeToSQLTimeStamp(StartDate);
ParamByName(End).AsSQLTimeStamp := DateTimeToSQLTimeStamp(EndDate);
--
Wayne Niddery - Logic Fundamentals, Inc. (www.logicfundamentals.com)
RADBooks: http://www.logicfundamentals.com/RADBooks.html
"It is error alone which needs the support of government. Truth can
stand by itself." - Thomas Jefferson
|
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|