Hi Ross,

The TDateTime's are just floating point values, so can't you just subtract
one from the other and return the Sign of the result?

Regards,

Bevan

---
Bevan Edwards    mailto:[EMAIL PROTECTED]
Achieve Software Limited  http://www.achieve.co.nz
Phone: (64-9) 444-4210   ICQ: 732011
Fax: (64-9) 444-4201
Mobile: (64-21) 979-603


----- Original Message -----
From: "Ross Levis" <[EMAIL PROTECTED]>
To: "Multiple recipients of list delphi" <[EMAIL PROTECTED]>
Sent: Friday, August 09, 2002 1:37 PM
Subject: [DUG]: CustomSort


> 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/
>

---------------------------------------------------------------------------
    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