I'm doing a ListView.CustomSort based on TDateTimes.  I'm trying to 
establish the best/fastest approach.  The CustomSort function requires 
an integer result of <0, 0 or >0 for the comparison of 2 dates.  Some of 
the dates will be 0 (ie 31/12/1899) so I can't do the following because 
the result will be bigger than an integer can hold.

Result := Trunc(SecsPerDay*(Item1.Date - Item2.Date));

Can someone think of a better approach than this:

if Item1.Date > Item2.Date then Result := 1
else if Item1.Date < Item2.Date then Result := -1
else Result := 0;

Cheers,
Ross Levis.

---------------------------------------------------------------------------
    New Zealand Delphi Users group - Delphi List - [EMAIL PROTECTED]
                  Website: http://www.delphi.org.nz
To UnSub, send email to: [EMAIL PROTECTED] 
with body of "unsubscribe delphi"
Web Archive at: http://www.mail-archive.com/delphi%40delphi.org.nz/

Reply via email to