Abaksoft Posted January 4, 2016 Posted January 4, 2016 Hello, How are you filtering Date on a UniDBGrid ? I am CASTING the DateField as VARCHAR and using Filter Demo technic. Is it a good way or is there more simple ? THX Quote
mhmda Posted January 4, 2016 Posted January 4, 2016 I prefer Query and use SQL query to filter data as you want... Quote
Abaksoft Posted January 4, 2016 Author Posted January 4, 2016 Thank you Mohammad, But really want to use the same technic DEMO without casting date as varchar. Quote
Abaksoft Posted January 4, 2016 Author Posted January 4, 2016 (edited) 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 January 8, 2016 by Abaksoft Quote
Abaksoft Posted January 7, 2016 Author Posted January 7, 2016 (edited) 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 January 8, 2016 by Abaksoft Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.