Sorting dates in lists and grids

Because LANSA dates are stored as numbers, any attempt to use the SortonClick property of a listview or Grid column for a field in DMY format will result the data being sorted incorrectly.

A simple workaround for this issue is to include the same data in YMD format in hidden column. When the user clicks in an attempt to sort the data, the click event for the column will be fired. In the event routine, add code to set the SortPosition and SortDirection properties of the hidden YMD field.

By testing the SortPosition and SortDirection with a simple IF statement, the dates can be forced to go from ascending to descending and vice versa.