||Re: filter on logical plus date field
Ken Mayer <email@example.com>
||Wed, 5 Jan 2022 21:07:06 -0800
On 1/5/2022 4:48 PM, Ken Mayer wrote:
> On 1/5/2022 4:10 PM, Rouke wrote:
>> In a table with a logical field 'returned' and a date field
>> 'dateofrtrn' I'm getting weird results when I set a filter to not
>> returned or isblank(dateofrtrn). I expect to see no records with a
>> tick in the 'returned' field and also to see no records other than a
>> blank value in the dateofrtrn field. However, I get the following (eg.
>> of three records):
>> set filt to not returned or isblank(dateofrtrn)
>> list returned, dateofrtrn for recno()=2 or recno()=3 or recno()=14
>> Record# returned dateofrtrn
>> 2 .F. / /
>> 3 .F. 22/12/2013
>> 14 .T. / /
>> I expect only records like 2. Why are records 3 and 14 listed?
> "not returned" can include items that will appear as false when you
> query them, but may be "null" or empty.
> set filter to returned=.f. or isblank(dateofrtrn)
> (If you're using current versions of dBASE, you can also use the word
> "false" or the word "true" rather than the clunky ".t." and ".f." ... I
> assume you are, since you're using "not" instead of ".not" and "or"
> instead of ".or.")
And Heinz has a good point (I answered too quickly without reading
everything), rather than "or", from what you're saying about what you
are expecting, you want to be using "and" -- logical decisions can be
With "or", if the item on other side of "or" evaluates to true, the
whole check equates to true. With "and", both items on either side of
the word "and" must evaluate to true for the statement to be true. If
one of them is false, the whole thing is false.
Hope that helps.
Ken's dBASE Page: http://www.goldenstag.net/dbase
The dUFLP: http://www.goldenstag.net/dbase/index.htm#duflp
dBASE Books: http://www.goldenstag.net/dbase/Books/dBASEBooks.htm
dBASE Tutorial: http://www.goldenstag.net/dbase/Tutorial/00_Preface.htm
dBASE Web Tutorial: http://www.goldenstag.net/dbase/WebTutorial/00_Menu.htm