Board index » delphi » Problem with TTable.Filter and Format Date

Problem with TTable.Filter and Format Date

I have a problem with TTable.Filter and Format Date.

When I set  Local Short date Format PC  to 'dd-MM-aaaa' and
DateSeparator to '/' in Regional Configuration.

After that I set the gloval variables

     ShortDateFormat    := 'DD/MM/YYYY';
     DateSeparator     := '/';

and  I set Table.Filter

Table.Filtered := False;
Table.Filter := 'NOT( (PRO_DESDE > ' + datetostr(encodedate(ano,1,1)) +
') and ( PRO_HASTA < ' + datetostr(encodedate(ano,12,31)) +'))';
Table.Filtered := True;

Then the problem appears with the message

Arithmetic in filter expresions not support

I suppose that  the caracter '/' is not useded in the right way.

---------------------------------
Remigio Eliseo Contreras Camus
rcont...@gopher.cchen.cl

 

Re:Problem with TTable.Filter and Format Date


Try QuoteStr.
I grabbed an example from another post:
Table2.Filter := 'PCD = ' + QuotedStr(Edit1.Text + '*');

You still might have a problem getting the effect you want filtering on
dates though.

"Remigio Contreras Camus" <rcont...@gopher.cchen.cl> wrote in message
news:3842BD71.782C8E43@gopher.cchen.cl...

Quote
> I have a problem with TTable.Filter and Format Date.

> When I set  Local Short date Format PC  to 'dd-MM-aaaa' and
> DateSeparator to '/' in Regional Configuration.

> After that I set the gloval variables

>      ShortDateFormat    := 'DD/MM/YYYY';
>      DateSeparator     := '/';

> and  I set Table.Filter

> Table.Filtered := False;
> Table.Filter := 'NOT( (PRO_DESDE > ' + datetostr(encodedate(ano,1,1)) +
> ') and ( PRO_HASTA < ' + datetostr(encodedate(ano,12,31)) +'))';
> Table.Filtered := True;

> Then the problem appears with the message

> Arithmetic in filter expresions not support

> I suppose that  the caracter '/' is not useded in the right way.

> ---------------------------------
> Remigio Eliseo Contreras Camus
> rcont...@gopher.cchen.cl

Re:Problem with TTable.Filter and Format Date


Quote
>Table.Filtered := False;
>Table.Filter := 'NOT( (PRO_DESDE > ' + datetostr(encodedate(ano,1,1)) +
>') and ( PRO_HASTA < ' + datetostr(encodedate(ano,12,31)) +'))';
>Table.Filtered := True;

>Then the problem appears with the message

>Arithmetic in filter expresions not support

use
Table.Filter := 'NOT( (PRO_DESDE > ' + quotedStr(datetostr(encodedate(ano,1,1))
)
--
Brian Bushay (TeamB)
Bbus...@NMPLS.com

Other Threads