Board index » delphi » Table.Filter: Filtering between dates

Table.Filter: Filtering between dates

Hello newsgroup!

What in heaven's name is wrong with that filter statement?
Probably it's very simple but I can' find the mistake I made:

tbPersonal.Filter := 'EINTRITT BETWEEN '''+dbvon.Text+''' AND  
''+dbbis.Text+''' OR EHEMALSSEIT BETWEEN '''+dbvon.Text+''' AND  
'''+dbbis.Text+'';
tbPersonal.Filtered := True;

The error message I get is something about an incomplete term.

I would be thankful for every idea that helps.

Peter

 

Re:Table.Filter: Filtering between dates


Hello newsgroup!

What in heaven's name is wrong with that filter statement?
Probably it's very simple but I can't find the mistake I made:

tbPersonal.Filter := 'EINTRITT BETWEEN '''+dbvon.Text+''' AND  
'''+dbbis.Text+''' OR EHEMALSSEIT BETWEEN '''+dbvon.Text+'''
AND  
'''+dbbis.Text+'';
tbPersonal.Filtered := True;

The error message I get is something about an incomplete term.

I would be thankful for every idea that helps.

Peter

Re:Table.Filter: Filtering between dates


Hello newsgroup!

What in heaven's name is wrong with that filter statement?
Probably it's very simple but I can't find the mistake I made:

tbPersonal.Filter := 'EINTRITT BETWEEN '''+dbvon.Text+''' AND  
'''+dbbis.Text+''' OR EHEMALSSEIT BETWEEN '''+dbvon.Text+'''
AND  
'''+dbbis.Text+'';
tbPersonal.Filtered := True;

The error message I get is something about an incomplete term.

I would be thankful for every idea that helps.

Peter

Re:Table.Filter: Filtering between dates


On Fri, 26 May 2000 12:41:12 +0200, Peter Bartelt

Quote
<pbart...@softaktiv.de> wrote:
>What in heaven's name is wrong with that filter statement?
>Probably it's very simple but I can' find the mistake I made:

>tbPersonal.Filter := 'EINTRITT BETWEEN '''+dbvon.Text+''' AND  
>''+dbbis.Text+''' OR EHEMALSSEIT BETWEEN '''+dbvon.Text+''' AND  
>'''+dbbis.Text+'';
>tbPersonal.Filtered := True;

>The error message I get is something about an incomplete term.

You need 4 single quotes at the end of your statement to get one quote
in the resulting filter expression.  You can also avoid these
complications by using the QuotedStr() function:
  tbPersonal.Filter := 'EINTRITT BETWEEN '+QuotedStr(dbvon.Text)+
    ' AND '+QuotedStr(dbbis.Text)+' OR EHEMALSSEIT BETWEEN '+
    +QuotedStr(dbvon.Text)+' AND '+QuotedStr(dbbis.Text);

HTH,

Jan

Re:Table.Filter: Filtering between dates


In article <392e71dc.194001...@forums.inprise.com>,
j...@nospamplease.adm2000.be says...
Quote
> On Fri, 26 May 2000 12:41:12 +0200, Peter Bartelt
> <pbart...@softaktiv.de> wrote:

> >What in heaven's name is wrong with that filter statement?
> >Probably it's very simple but I can' find the mistake I made:

> >tbPersonal.Filter := 'EINTRITT BETWEEN '''+dbvon.Text+''' AND  
> >''+dbbis.Text+''' OR EHEMALSSEIT BETWEEN '''+dbvon.Text+''' AND  
> >'''+dbbis.Text+'';
> >tbPersonal.Filtered := True;

> >The error message I get is something about an incomplete term.

> You need 4 single quotes at the end of your statement to get one quote
> in the resulting filter expression.  You can also avoid these
> complications by using the QuotedStr() function:
>   tbPersonal.Filter := 'EINTRITT BETWEEN '+QuotedStr(dbvon.Text)+
>     ' AND '+QuotedStr(dbbis.Text)+' OR EHEMALSSEIT BETWEEN '+
>     +QuotedStr(dbvon.Text)+' AND '+QuotedStr(dbbis.Text);

> HTH,

> Jan

Hello Jan,

thank you for answering so quickly. Your code looks good.
Unfortunately I get the error message (in
german):"Filterausdruck fehlerhaft abgeschlossen".

Have you got a solution for me?

Peter

Re:Table.Filter: Filtering between dates


In article <MPG.1398dbf65077685a989...@newsgroups.borland.com>,
pbart...@softaktiv.de says...

Quote
> In article <392e71dc.194001...@forums.inprise.com>,
> j...@nospamplease.adm2000.be says...
> > On Fri, 26 May 2000 12:41:12 +0200, Peter Bartelt
> > <pbart...@softaktiv.de> wrote:

> > >What in heaven's name is wrong with that filter statement?
> > >Probably it's very simple but I can' find the mistake I made:

> > >tbPersonal.Filter := 'EINTRITT BETWEEN '''+dbvon.Text+''' AND  
> > >''+dbbis.Text+''' OR EHEMALSSEIT BETWEEN '''+dbvon.Text+''' AND  
> > >'''+dbbis.Text+'';
> > >tbPersonal.Filtered := True;

> > >The error message I get is something about an incomplete term.

> > You need 4 single quotes at the end of your statement to get one quote
> > in the resulting filter expression.  You can also avoid these
> > complications by using the QuotedStr() function:
> >   tbPersonal.Filter := 'EINTRITT BETWEEN '+QuotedStr(dbvon.Text)+
> >     ' AND '+QuotedStr(dbbis.Text)+' OR EHEMALSSEIT BETWEEN '+
> >     +QuotedStr(dbvon.Text)+' AND '+QuotedStr(dbbis.Text);

Hi Peter,

I find that using the Format function in addition to QuotedStr makes it
much easier to build filter expressions (and SQL for that matter).

Your filter expression would be:

tbPersonal.Filter := Format('EINTRITT BETWEEN %s AND %s OR
                             EHEMALSSEIT BETWEEN %s AND %s',
                            [QuotedStr(dbvon.Text),
                             QuotedStr(dbbis.Text),
                             QuotedStr(dbvon.Text),
                             QuotedStr(dbbis.Text)]);
tbPersonal.Filtered := True;

--
Carl

Re:Table.Filter: Filtering between dates


Quote
>What in heaven's name is wrong with that filter statement?
>Probably it's very simple but I can't find the mistake I made:

Probably because Between is not supported in Filters.

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

Re:Table.Filter: Filtering between dates


On Fri, 26 May 2000 20:08:09 +0200, Peter Bartelt

Quote
<pbart...@softaktiv.de> wrote:
>thank you for answering so quickly. Your code looks good.
>Unfortunately I get the error message (in
>german):"Filterausdruck fehlerhaft abgeschlossen".

Brian has probably given you the answer since most DBs don't support
complete SQL expressions in a filter.  You'll have to use
   A >= X and A <= Y
instead of
   A between X and Y

Jan

Re:Table.Filter: Filtering between dates


I could be very wrong but I don't think BETWEEN is a valid operator in
a filter, although it is valid in most SQL.

Try using the operators  >= and <= instead  

Regards,
Colin Acheson

On Fri, 26 May 2000 20:08:09 +0200, Peter Bartelt

Quote
<pbart...@softaktiv.de> wrote:
>> On Fri, 26 May 2000 12:41:12 +0200, Peter Bartelt
>> <pbart...@softaktiv.de> wrote:

>> >What in heaven's name is wrong with that filter statement?
>> >Probably it's very simple but I can' find the mistake I made:

Re:Table.Filter: Filtering between dates


Thank you all!

With your help I was able to finish my project successfully!

Peter

Other Threads