Re: filer table by a word ....
From: Jeremy Collins (jd.collins_at_ntlworld-not.com)
Date: Tue, 22 Mar 2005 07:55:59 GMT
sew crazy wrote:
>>Filter := Format('(TypeOfTransport = ''pad'') AND (Distance > %d) ',
> Is it possible for you to explain this notation espesially the %d
Format() lets you build a string that contains variables of other
types, without lots of ugly typecasting or calls to conversion
functions. It is extremely useful for building SQL statements.
The %d tells the Format function to replace it with an integer
value; in this case the contents of the DistanceGone variable.
It's a bit daunting at first, but read carefully "Format function"
and "Format strings" in the help file.
> how would i filter useing a MonthCalendar - have a field DateIn
Date handling is dependent on your DBMS (and I don't think you've
told us what that is yet). For Access or SQL Server you can usually
treat dates as strings, as long as you use ISO date format.
So something like:
DateStr, SQLStr : string;
DateStr := FormatDateTime('YYYY-MM-DD', MonthCalendar1.Date);
SQLStr := Format('SELECT * FROM tb_mytable WHERE DateIn = ''%s''',
-- jc Remove the -not from email