Finding a date on a list
doug at artsman.com
Sun Feb 14 21:11:30 UTC 2021
If you are out to find the last line that matches the date
do list.$sort($ref.TranDate,1) ## sort by date descending, although you could sort by ascending)
# 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
## 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
and search all lines, backwards, with condition
Arts Management Systems Ltd.
mailto:doug at artsman.com
Phone (403) 650-1978
> On February 14, 2021, at 9:47 AM, Martin Luce via omnisdev-en <omnisdev-en at lists.omnis-dev.com> 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
> Manage your list subscriptions at http://lists.omnis-dev.com
> Start a new message -> mailto:omnisdev-en at lists.omnis-dev.com
More information about the omnisdev-en