RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomClientDataSet.Filter Property

Specifies the text of the current filter.

Pascal
property Filter: string;
C++
__property AnsiString Filter;

Use Filter to specify a dataset filter. When filtering is applied to a client dataset, only the records that meet a filter's conditions are available to an application. Filter contains the string that describes the filter condition. The Filter property is effective only if the Filtered property is set to True. In this case, if you change the Filter property, the filter is automatically updated.  

The following table lists all the operators that can be used when defining a filter, as well as usage examples.

Operator or function comparisons 
Example 
Comment 
=  
State = 'CA'  
 
<>  
State <> 'CA'  
 
>=  
DateEntered >= '1/1/1998'  
 
<=  
Total <= 100,000  
 
>  
Percentile > 50  
 
<  
Field1 < Field2  
 
BLANK  
State <> 'CA' or State = BLANK  
Blank records do not appear unless explicitly included in the filter.  
IS NULL  
Field1 IS NULL  
 
IS NOT NULL  
Field1 IS NOT NULL.  
 
Logical operators  
 
 
and  
State = 'CA' and Country = 'US'  
 
or  
State = 'CA' or State = 'MA'  
 
not  
not (State = 'CA')  
 
Arithmetic operators  
 
 
+  
Total + 5 > 100  
Applies to numbers, strings, or date (time).  
-  
Field1 - 7 <> 10  
Applies to numbers, dates, or date (time).  
*  
Discount * 100 > 20  
Applies to numbers only.  
/  
Discount > Total / 5  
Applies to numbers only.  
String functions  
 
 
Upper  
Upper(Field1) = 'ALWAYS'  
 
Lower  
Lower(Field1 + Field2) = 'josp'  
 
Substring  
Substring(DateString,8) = '1998' | Substring(DateString,1,3) = 'JAN'  
Extracts a substring from the string named in the first argument, starting at the position specified in the second argument. The third argument represents the number of characters copied from the string to the substring. If the third argument is missing, the string is copied from the specified position until the end.  
Trim  
Trim(Field1 + Field2) | Trim(Field1, '-')  
Removes spaces from the beginning and the end of a string.  
TrimLeft(StringField) | TrimLeft(Field1, '$') <> ''  
Removes spaces from the beginning of a string.  
TrimRight(StringField) | TrimRight(Field1, '.') <> ''  
Removes spaces from the end of a string.  
DateTime functions  
 
 
Year  
Year(DateField) = 2000  
 
Month  
Month(DateField) <> 12  
 
Day  
Day(DateField) = 1  
 
Hour  
Hour(DateField) < 16  
 
Minute  
Minute(DateField) = 0  
 
Second  
Second(DateField) = 30  
 
GetDate  
GetDate - DateField > 7  
Represents current date and time.  
Date  
DateField = Date(GetDate)  
Returns the date portion of a date-time value.  
Time  
TimeField > Time(GetDate)  
Returns the time portion of a date-time value.  
Miscellaneous  
 
 
Like  
Memo LIKE '%filters%'  
Works like SQL-92 without the ESC clause. When applied to BLOB fields, FilterOptions determines whether case is considered.  
In  
Day(DateField) in (1,7)  
Works like SQL-92. Second argument is a list of values all with the same type.  
*  
State = 'M*'  
Wildcard for partial comparisons.  

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!