Hi Dragan, Good morning!
Thanks for your input...cool! i didn't know about RECNO(0)...Thanks again...J
>>Hi Jill,
>>
>>Is the situation similar to the following? Starting on Date1, a product has a certain price; on and after Date2, the same product has a different price, etc., so you want to locate the nearest date, >= the desired date.
>>
>>I have this situation; I just do SET NEAR ON, SEEK..., and SET NEAR OFF. Some additional adjustments are needed, like, if there is no exact match, go back to the previous record, and check whether you are not outside the range, i.e., you landed on another product, meaning that the desired product doesn't have a price for the desired date. Of course, I am assuming there is an index on the combination product + date.
>
>A little addition here - Set Order To ... descending. I was using a logic like this:
>
>
if seek()
> * ok, got the date
>else
> if not eof() and not bof()
> go recno(0)
> endif
>endif
>
>When the near value for the key exists, i.e. the key sought (seek()ed, to be correct) is between the least and the greatest values, then recno(0) is the recno() of the record with that key. This was introduced at some point in fox 2.x. The DESC part was crucial - recno(0) gives you the
next record after the key sought, but I wanted the last one; ordering the table descending simply reverses the roles of "next" and "previous".
>
>I used this approach for retroactively recalculating domestic currency amounts into foreign currency - basically the same situation as yours, with "price" being the price of money, aka exchange rate.
>
>p.s. Hi, Jill :)