Smiffy
21st February 2002, 14:51
Is it possible to have a reverse order index for a date field on a table.

Requirement:

A display session will show records from the sessions main table. The records are required to be displayed in descending date sequence. i.e. latest date first.

I have solved this previously by creating a new field on the table. Baan represents dates as a number (number of days since...). This number is subtracted from zero to give a negative version of the date. This is stored on the table as a long. When this new field on the table is set as an index, this results in the records being in reverse date order (when that index is selected as the sort sequence).

The question is; Is there an easier way to provide this facility, without having to create this new field?

alejandro
21st February 2002, 15:04
Try: in your select


order by ppmmxxx.ffff desc

where ffff is the name of the field.

You can use asc or desc options.

Hope this helps.

Smiffy
21st February 2002, 15:51
Sorry, but there is no select statement. The session is a display session with a main table. I think you are thinking of ordering data from other tables, besides the main table or ordering the data for a report etc.

ankybanky
22nd February 2002, 14:01
smiffy
You can use Query.extension for such cases in before.program section .
i hope this solves your query
do reply if this solves your query
regards ankur

shah_bs
23rd February 2002, 05:13
If you are planning to use the 'extra' field, I would suggest subtracting from MAXDATE instead of zeros. 'Negative' dates may come back and bite you sometime.

Using 'order by' in query.extension may have performance problems if the table is too big. (At least in BAAN IVc3).

NeilPengelly
11th September 2003, 21:31
You can use the following (BaanV only):

before.program:
query.extend.order("<fieldname> desc")

Looks like a hit on performance though.

-- Neil