Jump to content


Photo

Filter between two Dates?

Filter between two Dates?

  • Please log in to reply
3 replies to this topic

#1 Cacki

Cacki
  • Members
  • 2 posts

Posted 25 April 2014 - 04:45 PM

Hi Boki

I would like a filter program for a date between two dates
For example, show me all data rows between 24.04.2014 and 28.04.2014 (Filter)

I always get an error message' operator is not applicable to this operand type'
Can you give me a tip

or a little code?

this code is running but its only one date < as calendar1 all other rows are unvisible.

nextgrid1.beginupdate
if nextgrid1.RowCount>1 then
for i:=0 to nextgrid1.RowCount-1 do
if cb2.ItemIndex =0 then
if nextgrid1.CellByName[1,i].AsDateTime <(calendar1.Date) then
nextgrid1.RowVisible[i]:=false;

Version Grid 5.7
best regards Carsten

#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 25 April 2014 - 09:14 PM

Hi,

In v6 there is a automatic filtering for dates between.

In v5 I suggest that you use some of functions from Delphi's DateUtils unit. I am not sure at the moment about all functions, but I am sure that there is a something like datebetween.
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 Cacki

Cacki
  • Members
  • 2 posts

Posted 26 April 2014 - 08:19 PM

Hallo Boki


this is the solution that I have used
//Between
nextgrid1.BeginUpdate;
for i:=0 to nextgrid1.RowCount-1 do
if (nextgrid1.CellByName[1,i].AsDateTime<(calendar1.Date))or (nextgrid1.CellByName[1,i].AsDateTime>(calendar1.EndDate))then
nextgrid1.RowVisible[i]:=false;
nextgrid1.EndUpdate;

Regards

#4 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,289 posts
  • Gender:Male

Posted 02 May 2014 - 07:18 AM

Hi,

I think that you may need next function:
http://docwiki.embar...ils.DateInRange

It returns boolean. I suggest that you put result of this function into var like IsRowVisible = DateInRange(....)
and then NextGrid1.RowVisible[x] := IsRowVisible;

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users