[Lazarus] Filtering on date with TDbf

Koenraad Lelong lazarus1 at de-brouwerij.be
Thu Feb 2 10:45:11 CET 2012


On 01-02-12 17:00, shoKwave wrote:
> Hi,
>
> IIRC, first of all you need an index based on the field(s) you want to
> filter. The error is shown because the index "DATUM" doesn't exists.
> Here is the real problem, I don't know how to create an index of ftDate.
> If I try an error is shown because only string and float fields are
> allowed. But you could convert your database and store all dates as
> strings. To format the date right you can use
>
> procedure TForm1.FormCreate(Sender: TObject);
> begin
> DefaultFormatSettings.DateSeparator:='.';
> DefaultFormatSettings.ShortDateFormat:='yyyy.mm.dd';
> ...
> end;
>
> With this lines DateToStr() should convert it right.
>
> The filter property wants the name of the filter to compare with, not
> the name of the field.
>
> dbf1.Filter:='INDEXNAME>='+QuotedStr(DateToStr(XferStart));
> dbf1.Filtered:=true;
>
> If the date-field is of ftString, the dates are correctly formatted and
> the index is build it should work.
>
> Hope this helps.
>
> regards
>
> Ingo

Hi Ingo,

Unfortunately, this does not help. The application I'm writing extracts 
data from the database. The input into the database is handled by an old 
application (dbase or a derivate), and I don't have the sources of it. 
So I can't modify the database.

If there is no solution, I will have to stick with Delphi then.
Is this a deliberate omission, or a bug ? Should I file a bugreport ?

Thanks,

Koenraad.




More information about the Lazarus mailing list