Filtering by date difference

Googmorning to all,

in my grid in column 5 i stored date information.

I'm sure that there is a way ... but now i miss it...

I need to filter the grid for a date difference, i.e. all items present for 30 days or more.

Which is the correct string to use in the Filter.Condition

Something like cellvalue - date >= 30.

Im don't know how isert the cellvalue into the string.



Thank's for all



Regards



Daniele



This shows how you can filter based on a min & max date:


procedure TForm1.Button1Click(Sender: TObject);
var
  fd: TFilterData;
begin
  AdvStringGrid1.Filter.Clear;
  fd := AdvStringGrid1.Filter.Add;
  fd.Column := 3;
  fd.Condition := '>1/4/2017 & <1/5/2017';
  AdvStringGrid1.FilterActive := true;
end;

procedure TForm1.FormCreate(Sender: TObject);
var
  i: integer;
begin
  AdvStringGrid1.RowCount := 100;
  AdvStringGrid1.RandomFill(false);

  for i := 1 to AdvStringGrid1.RowCount - 1 do
  begin
    AdvStringGrid1.Dates[3,i] := Now + random(60);
  end;
end;

Good morning Bruno,

thank's for your reply.

My problem with this type of filtering is quite "strange"

The filter is setted for difference between two date, but this difference is on the cells date and the delta applied.



To make it easy to understand i need to show only the rows where the date stored in column 5 is grater the his own date + 10 days



Is it possible ?



Thank's for reply and have a nice day.



Daniele

In this case, I'd suggest to add a (hidden) column that contains just the data difference and then do a filtering on this hidden column.

Hi Bruno,

the way you suggested is not applicable because there are two problems

1) the date is different for each row

2) is the user who decides which is the "delta"



Is not a bad idea, as new feature, make something like



Column:=5;

Condition ='Self >'



Where Self is it's own value.



Last question (to be honest i made this question some time ago):

There is the possibility to "disconnect" the grid from the graphic until all the work is done?

Similar to DBGrid.DisableControls



Thank's for all



Have a nic weekend



Daniele

If you mean you want to block painting, have you tried:


grid.BeginUpdate;
// do work here
grid.EndUpdate;

Hi Bruno,

yes it was that.



Thank's



Good WeekEnd



Daniele