Filter_Expression as C = between_num(C field ,N num1 ,N num2 )



A character filter expression that evaluates to a logical value and selects records from a table.


The name of a field that you wish to write a filter expression against.


A numeric variable or value that contains the first or lowest value to include in the filter. Numeric


A numeric variable or value that contains the last or highest value to include in the filter. Numeric


Creates a string using the Between() function


BETWEEN_NUM() returns a character filter expression that uses the two number values and selects records from the table. This function is only useful in Xbasic scripts. Field_Name is a numeric field or expression to search on. Low_Value and High_Value are numeric variables. They are the first and last values in a range of records to find. Frequently in Xbasic scripts, you need to specify a filter expression in quotes. It can get quite tricky to do this if your Low_Value and High_Value values are stored in variables. For example, the following code fragment shows how to specify a filter expression for an Xbasic query:

dim shared First as N 
dim shared Last as N
t = tbl.open("customer") 
query.filter = "between(qty, " + First + ", "  + Last + ")" 

Assuming that First contains 3, and Last contains 10, query.filter will contain the following value:

"between(qty, 3, 10)"

This is a valid filter expression. However, it is very cumbersome to write the expression that defines the query.filter variable. The BETWEEN_CHAR() utility function makes it easier to write this filter expression. For example:

query.filter = between_num("qty", First, Last)

If you are searching on fields/expressions of other types, use the appropriate utility function. Assuming that lastname, qty, and invoice_date are field names.

Field Type
Function and Example

BETWEEN_CHAR(): between_char("lastname", first, last)


BETWEEN_NUM(): between_num("qty", first, last)


BETWEEN_DATE(): between_date("invoice_date", first, last)

Record number

BETWEEN_RECORD(): between_record(first, last)

between_char("Lastname","Smith", "Jones")  -> "between(lastname, \"Smith\", \"Jones\")"
between_num("Qty", start, end) -> "between(qty,  3, 10)", assuming the start and end variables contain 3 and 10
between_date("Invoice_Date", start, end) -> "between(invoice_date, {1/1/2000}, {12/31/2000})",  assuming the start and end variables contain {1/1/2000} and {12/31/2000}.
between_record(start, end) -> "between(recno() , 3,  10)", assuming the start and end variables contain 3 and 10  'The following example shows how these functions can be used in situations where a quoted filter string is expected:'(Note that since the function RETURNS a quoted string, it is not necessary to quote the value assigned to query.filter)query.filter = between_char("Lastname","Smith","Jones")query.order = "Lastname"dim tbl as p dim i as p tbl = table.open("customers")i = tbl.query_create()  startDate = {1/1/2007}endDate = {1/31/2008}query.filter = between_date("OrderDate",startDate,endDate)query.order = "OrderId"tbl = table.open("Orders")i = tbl.query_create()

See Also