BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

SQL and date parameters

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress)
View previous topic :: View next topic  
Author Message
Nenad Blagojevic
Guest





PostPosted: Tue Nov 18, 2003 3:33 pm    Post subject: SQL and date parameters Reply with quote



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





PostPosted: Tue Nov 18, 2003 4:35 pm    Post subject: Re: SQL and date parameters Reply with quote



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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi Databases (dbExpress) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.