Subject Ordering of date field
Author Aage Johansen
Using IB_SQL/4.5B with Fb/1.5.3.

While chasing "strange" dates in a database I used this:
select LANSERT, count(*)
from DISTRIB
where extract(year from LANSERT) < 1910 or
extract(year from LANSERT) >= 2010
group by LANSERT
order by extract(year from LANSERT),
extract(month from LANSERT),
extract(day from LANSERT)
and it works fine. The output was like:
12.01.0205 1
08.12.0404 1
...
08.12.1197 1
01.01.1900 4
...
05.12.2205 1


Now, if I drop the "order by" or change it to just "order by LANSERT":
select LANSERT, count(*)
from DISTRIB
where extract(year from LANSERT) < 1910 or
extract(year from LANSERT) >= 2010
group by LANSERT
order by LANSERT
It results in this:
08.12.1197 1
...
08.12.0404 1
12.01.0205 1
01.01.1900 4
...
05.12.2205 1
It seems that the date field (LANSERT) is sorted _descending_ for
years before (about) 1870!

(Of course, I first saw the mixed descending/ascending sequence, then
added the "order by" to work around it)

--
Aage J.