Finding a date on a list

Doug Easterbrook doug at
Sun Feb 14 21:11:30 UTC 2021

hi Martin.

If you are out to find the last line that matches the date

searchdate=’some date’

do list.$sort($ref.TranDate,1)    ## sort by date descending, although you could sort by ascending)
do list.$search($ref.TranDate<=searchdate,ktrue,kfalse,ktrue,ktrue)

# search selected lines, forward.

do list.$first(ktrue) returns #F    <— finds FIRST line where date <= .. but list is sorted in reverse order, so its last date.

or if you want to sort the list ascending, search for the LAST line

do list.$sort($ref.TranDate,0)    ## sort ascending
do list.$search($ref.TranDate<=searchdate,ktrue,kfalse,ktrue,ktrue)

## search selected lines, backward

do list.$first(ktrue,ktrue) returns #F    <— finds LAST line where date <= tran date

and in reading the $first() documentation there is a third parameter called condition.  I’ve next used it but it implies you could do the following.    Now that I know of the condition….  I may try it in some code

searchdate=’some date’
do list.$sort($ref.TranDate,0) 

and search all lines,   backwards,   with condition

do list.$first(kfalse,ktrue,$ref.TranDate<=searchdate)

Doug Easterbrook
Arts Management Systems Ltd.
mailto:doug at
Phone (403) 650-1978

> On February 14, 2021, at 9:47 AM, Martin Luce via omnisdev-en <omnisdev-en at> wrote:
> Hi All
> Help please
> I have a list of stock transactions with dates. I am trying to get the last transaction date which is less than or equal to the date I am looking at so that I can get what was in stock at the date I am searching on. I cannot see how to do it with notation on a list. I am sure that there must be a way.
> Many thanks
> Martin
> _____________________________________________________________
> Manage your list subscriptions at
> Start a new message -> mailto:omnisdev-en at 

More information about the omnisdev-en mailing list