Subject | Re: [IBO] Dates in TIBOQuery vs. PrepareSQL |
---|---|
Author | Helen Borrie |
Post date | 2005-10-13T00:57:53Z |
Tony,
At 03:35 PM 12/10/2005 +0000, Tony Masefield wrote:
As Alan pointed out, doubling is the correct way to escape apostrophes in
Pascal (and in Firebird, as well, as it happens!)
However, relying on date literals in SQL from the client side is not the
recommended way to do this, if it can possibly be avoided. Use parameters
and then, in your "before" event, use AsDate or AsDateTime to assign the date.
viz.
MyDataset.SQLWhereItems.Add('where ADate >= :ADate');
Then (assuming you're using the search in a dataset):
MyDataset.ParamByName('ADate').AsDateTime := YourDateTimeVariable;
Helen
At 03:35 PM 12/10/2005 +0000, Tony Masefield wrote:
>Thanks Alan, missed the two single apostophes vs. the doubleFirst, PLEASE TRIM YOUR MESSAGES !!!
>apostrophe. Now working fine. This construct is a little peculiar
>(at least to me).
As Alan pointed out, doubling is the correct way to escape apostrophes in
Pascal (and in Firebird, as well, as it happens!)
However, relying on date literals in SQL from the client side is not the
recommended way to do this, if it can possibly be avoided. Use parameters
and then, in your "before" event, use AsDate or AsDateTime to assign the date.
viz.
MyDataset.SQLWhereItems.Add('where ADate >= :ADate');
Then (assuming you're using the search in a dataset):
MyDataset.ParamByName('ADate').AsDateTime := YourDateTimeVariable;
Helen