Gustav Brock
Gustav at cactus.dk
Thu Apr 6 06:29:01 CDT 2006
Hi all
Are you aware that old dates - those with negative value, prior to 1899-12-30 - do not sort correctly if they contain a time part?
You may never need it but if you do, the usual method is to use Format:
SortDate = Format([DateField], "yyyymmddhhnnss")
and sort on that, but it is slow.
Another and faster method is this:
SELECT
*
FROM
tblDates
ORDER BY
Fix([DateField]),
Abs([DateField]);
Fix takes care of keeping the dates in correct sequence (Int can not be used!) while Abs for a given date allows to sort the timepart correctly.
/gustav