Jump to content

Filtering Date on DbGrid


Abaksoft

Recommended Posts

I used this and works fine  :)

(FireBird SQL)

 

 
  Mydate:='substring(100+extract(day from DateN) from 2 for 2)  ||''/''|| '+
                 'substring(100+extract(month from DateN) from 2 for 2)||''/''|| '+
                 'extract(year from DateN)';
 
 
  SQL:='Select ' +    Mydate  +  ' as DateN2 From TCustomers ' +
            ' Where (  ('+   Mydate   + ' Like :DateN2) Or (DateN is NULL) )' ;
 

 

This CAST the Date Field in string and enable to Filter it on the UniDBGrid as Demo.

Greetings....

_____

PS : Casting date as varchar seems to be an obligation !

Edited by Abaksoft
Link to comment
Share on other sites

In fact, sending a Query from huge data,every 250 milliseconds as Demo "Filtering2" is depreciated.
I use instead this :
1. Open once the query without params (to see all records even Null records)

 

2. OnClearFiler (UnidbGrid) :
YourDataset.Filtred:=False;

3. OnFiltering (UnidbGrid) :
- Build your string filter F for all enabled columns filter

- then yourDataSet.Filter:= F;
yourDataSet.Filtred:= True;

It's very Fast :)
Regards.

 

 

Modified today:

____

PS :  in (1) opening the Query without params  and without ....( And DateN is NULL) 

 

 Mydate:='substring(100+extract(day from DateN) from 2 for 2)  ||''/''|| '+
                 'substring(100+extract(month from DateN) from 2 for 2)||''/''|| '+
                 'extract(year from DateN)';
  SQL:='Select ' +    Mydate  +  ' as DateN2 From TCustomers ';
Edited by Abaksoft
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...