Recent

Author Topic: Paradox date filter  (Read 600 times)

tawfiq-lz

  • New Member
  • *
  • Posts: 11
Paradox date filter
« on: November 08, 2025, 04:40:27 am »
hello guys ,
So i have a little app in lazarus and i am forced to retreive some informations from a Paradox database (table), i am trying to use a filter on some date field ( stored in paradox as date ) .. i tried all those lines .. but no one works :

-PrdxDataset1.Filter:='DATE_FICHE = "2025/05/03"';
-PrdxDataset1.Filter:='DATE_FICHE = "03/05/2025"';
-PrdxDataset1.Filter:='DATE_FICHE = #2025/05/03#';
-PrdxDataset1.Filter:='DATE_FICHE = #03/05/2025#';
-PrdxDataset1.Filter:='DATE_FICHE =' +  QuotedStr(2025/05/03);
-PrdxDataset1.Filter:='DATE_FICHE = "20250503"';
-PrdxDataset1.Filter:='DATE_FICHE = "03052025"';

please help me !!

bytebites

  • Hero Member
  • *****
  • Posts: 767
Re: Paradox date filter
« Reply #1 on: November 08, 2025, 08:25:44 am »
Just a guess
PrdxDataset1.Filter:='DTOS(DATE_FICHE) = "20250503"';

tawfiq-lz

  • New Member
  • *
  • Posts: 11
Re: Paradox date filter
« Reply #2 on: November 09, 2025, 02:29:47 pm »
Just a guess
PrdxDataset1.Filter:='DTOS(DATE_FICHE) = "20250503"';


didnt work too

dsiders

  • Hero Member
  • *****
  • Posts: 1496
Re: Paradox date filter
« Reply #3 on: November 09, 2025, 05:21:48 pm »
Just a guess
PrdxDataset1.Filter:='DTOS(DATE_FICHE) = "20250503"';

Another guess...

Code: Pascal  [Select][+][-]
  1. PrdxDataset1.Filter := 'DTOS(DATE_FICHE) = ' + QuotedStr('#03/25/2025#');
Preview the next Lazarus documentation release at: https://dsiders.gitlab.io/lazdocsnext

tawfiq-lz

  • New Member
  • *
  • Posts: 11
Re: Paradox date filter
« Reply #4 on: November 09, 2025, 05:31:40 pm »
Just a guess
PrdxDataset1.Filter:='DTOS(DATE_FICHE) = "20250503"';

Another guess...

Code: Pascal  [Select][+][-]
  1. PrdxDataset1.Filter := 'DTOS(DATE_FICHE) = ' + QuotedStr('#03/25/2025#');


didnt work too

paweld

  • Hero Member
  • *****
  • Posts: 1525
Re: Paradox date filter
« Reply #5 on: November 09, 2025, 06:10:16 pm »
Try;
Code: Pascal  [Select][+][-]
  1. PrdxDataset1.Filter := 'year(DATE_FICHE)=2025 AND month(DATE_FICHE)=5 AND day(DATE_FICHE)=3';
  2. PrdxDataset1.Filtered := True;
Best regards / Pozdrawiam
paweld

tawfiq-lz

  • New Member
  • *
  • Posts: 11
Re: Paradox date filter
« Reply #6 on: November 09, 2025, 06:27:12 pm »
Try;
Code: Pascal  [Select][+][-]
  1. PrdxDataset1.Filter := 'year(DATE_FICHE)=2025 AND month(DATE_FICHE)=5 AND day(DATE_FICHE)=3';
  2. PrdxDataset1.Filtered := True;

thanx for the try , but it didnt work too .. i think the problem is in this TParadoxDataSet

wp

  • Hero Member
  • *****
  • Posts: 13268
Re: Paradox date filter
« Reply #7 on: November 09, 2025, 06:53:14 pm »
Maybe you should be more specific on how you opened the paradox database: ODBC? The paradox component which comes with Lazarus (components/paradox)? The TParadoxDataset from CCR (or OPM)?

I am using the latter one occasionally for viewing old paradox files and/or converting them to sqlite3 (https://github.com/wp-xyz/ParadoxViewer). Trying now to filter records I am stuck with the same issue: Filtering works for string or integer fields (ParadoxDataset.Filter := 'StringField="A*"';), but fails for date fields, just as you are reporting. I noticed that filtering goes through the TBufdataset expression engine and thus should comply to the same rules working for example TDbf, such as the expression ParadoxDataset.Filter := 'DTOS(DateField)="20001231". Interestingly this one does not raise an expression, but leaves an empty row in my DBGrid, and finally the application crashes when the mouse is moved into the grid so that it must be redrawn (*). I speculate that TParadoxDataset has an issue here?

What certainly is working for sure is to provide a handler for the OnFilterRecord event:
Code: Pascal  [Select][+][-]
  1. procedure TForm1.ParadoxDataset1FilterRecord(DataSet: TDataSet;
  2.   var Accept: Boolean);
  3. var
  4.   dt: TDate;
  5. begin
  6.   dt := Dataset.FieldByName('DateField').AsDateTime;
  7.   Accept := (dt = EncodeDate(2000,12,31));
  8. end;

(*)
I just have been able to fix this: The crash happened when a popup hint would appear over the empty grid row when the filter had returned only an empty dataset. In dbgrids.pas, the line "if (F <> nil)" must be extended to "if (F <> nil) and not F.IsNull" in function TCustomDBGrid.GetTruncCellHintText.
« Last Edit: November 09, 2025, 08:17:14 pm by wp »

tawfiq-lz

  • New Member
  • *
  • Posts: 11
Re: Paradox date filter
« Reply #8 on: November 09, 2025, 07:46:20 pm »
thanx alot  wp yourcode worked for me .

 

TinyPortal © 2005-2018