Hi, I'm fairly new to programming with Lawson so excuse me if this is a foolish question. Any help is greatly appreciated.
In any table, what is the best way to retrieve the most recent or MAX date or MIN date for that matter? When I tried using the 880 Aggregate functions the compiler complained that it wouldn't work with date fields.
The only way I've come up with is to use a bubble routine.
Some tables have a date as a key in one of the index's. You could potentially use that index. Else, some kind of SORT is what I use.
Ragu
I've been using a sort when there is no key available. I kinda figured that was what I needed to be doing. Thanks for confirming my hunch.
Bubble sort is not what you want. If you want to do it programmatically, you need only to write a one-pass routine. A Sort routine arranges all items in a list in order. Since all that you're looking for is a maximum (or minimum), you only need a single pass through the data. Keep track of the highest (or lowest) value found, while comparing against each record's value.
I like Ragu's idea of an index, though. That's slick, requires minimum coding, it's lightning fast, and maintains itself. You can add your own index to a file using DBDEF. Then, all you have to do is to open the first record, and your date will be there.
Just remember to make a note of the customization, so that you can re-apply it if a CTP or MSP wipes it out.
Thanks!
I'll make sure I go that route.