Find Last

nate100

Member
Say if I have the following records in the table:

BB0906071
BB0906191
BB0906192
BB090619M


What I like to do is to search the last record that begin with BB and the current YYMMDD and any characters after is a character that can be made into an integer so that I can add a sequence to it by incrementing by 1. If it is a alpha character, then I would need to go to the previous record until I find one that has BB and then the date format for today and then a chacter that is an integer.

In the above sample, even though finding the last record I get BB090619M, I need to byplass this as M is not something that I can change to an integer. Thus, I need need to go the previous record of BB0906192 and increment by 1 to get me BB0906193.

I was wondering what the best way to do this would be. I was wondering if I could use a find last where string begins with DDYYMMDD and check to make sure that anything after that is a character that is an integer in one Find last statement.

Find Last table where table.fld1 begins "BB<YYMMDD>" AND....

Thanks in advance.
 
i'm not quite sure if there is a specific function for that - if it isn't so here would be a souluten that works:

use a for each - order by this value descending.

seperate the last char - check if it is numeric - if not skip to next record.....

might help

regards

cugar
 
The other answer is "don't do that". Cobbled together keys like this are a recipe for trouble. Just make some separate fields that have meaning and life will be simpler.
 
Composite keys are evil. Violations of relational purity always come back to haunt you ;)

But if you must do this then cugar's way with a FOR EACH ... BY will work better than any variety of FIND LAST (which is also evil).
 
Back
Top