Board index » delphi » Filtering in Date field

Filtering in Date field

Hi,

i have a problem. I create table (TableProduction) with primary index
combined with two key field (Artcode and Date). When program call Qreport to
print all events grouped on ArtCode is O.K., but when i try to print just
ArtCodes which happened between  two dates, Qreport show me all ArtCodes.
Before this I put TableProduction on filter:

TableProduction.Filtered:=False;
TableProduction.Filter:='DateField >'+ ChosenDate1+ 'and'+'DateField
<'+ChosenDate2;
TableProduction.Filtered:=True;
..
I need only those records in table inside of these two dates!

Thank you,
                               Denis
                        denis_no...@hotmail.com

 

Re:Filtering in Date field


Quote
Test wrote:

> Hi,

> i have a problem. I create table (TableProduction) with primary index
> combined with two key field (Artcode and Date). When program call Qreport to
> print all events grouped on ArtCode is O.K., but when i try to print just
> ArtCodes which happened between  two dates, Qreport show me all ArtCodes.
> Before this I put TableProduction on filter:

> TableProduction.Filtered:=False;
> TableProduction.Filter:='DateField >'+ ChosenDate1+ 'and'+'DateField
> <'+ChosenDate2;
> TableProduction.Filtered:=True;
> ..
> I need only those records in table inside of these two dates!

> Thank you,
>                                Denis
>                         denis_no...@hotmail.com

Shouldn't your second line read..

TableProduction.Filter:='DateField >"'+ ChosenDate1+'" .and. 'DateField'
<"'+ChosenDate2+'"';

Re:Filtering in Date field


Quote
>TableProduction.Filtered:=False;
>TableProduction.Filter:='DateField >'+ ChosenDate1+ 'and'+'DateField
><'+ChosenDate2;
>TableProduction.Filtered:=True;
>..
>I need only those records in table inside of these two dates!

Dates in filters should be in quotes

TableProduction.Filter:='DateField >'+ quotedStr(ChosenDate1)+ ' and '
+'DateField <'+quotedStr(ChosenDate2);

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Re:Filtering in Date field


Quote
Brian Bushay TeamB wrote:

> >TableProduction.Filtered:=False;
> >TableProduction.Filter:='DateField >'+ ChosenDate1+ 'and'+'DateField
> ><'+ChosenDate2;
> >TableProduction.Filtered:=True;
> >..
> >I need only those records in table inside of these two dates!

> Dates in filters should be in quotes

> TableProduction.Filter:='DateField >'+ quotedStr(ChosenDate1)+ ' and '
> +'DateField <'+quotedStr(ChosenDate2);

> --
> Brian Bushay (TeamB)
> Bbus...@NMPLS.com

Why is that?  I use dates in filters all the time under datetime
variables and have never had a problem.  But then of course I am using
the filter event handlers....

Re:Filtering in Date field


Quote
>Why is that?  I use dates in filters all the time under datetime
>variables and have never had a problem

It is just the way BDE likes it but that is also the way you use a date literal
in SQL

--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads