BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Stringgrid date sorting not working correctly

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal
View previous topic :: View next topic  
Author Message
th0r1000
Guest





PostPosted: Tue Jan 16, 2007 4:56 pm    Post subject: Stringgrid date sorting not working correctly Reply with quote



Hi there,

I am doing a quicksort on a stringgrid, everything works except when
i'm sorting by date. I get something similar to this.

01/02/06
02/02/06
03/02/06
04/01/06
05/02/06

I'm using the same quicksort code everyone is I just modified the
strcompare function to this

function compare(val1,val2:string):integer;
var
int1,int2:integer;
float1,float2:extended;
tDate1,tDate2: TDateTime;
dat1,dat2: TDate;
errcode:integer;
tempFormat: TFormatSettings;
begin
case datatype of
0: result:=ANSIComparetext(val1,val2);
1: begin
int1:=strtointdef(val1,0);
int2:=strtointdef(val2,0);
if (int1>int2) then result:=1
else if int1<int2 then result:=-1
else result:=0;
end;

2: begin
val(val1,float1,errcode);
if errcode<>0 then float1:=0;
val(val2,float2,errcode);
if errcode<>0 then float2:=0;
if float1>float2 then result:=1
else if float1<float2 then result:=-1
else result:=0;
end;
Quote:
3: begin
dblDiff:=StrToDate(Val2)-StrToDate(Val1);
if (dblDiff = 0) then
result:=0
else if (dblDiff < 0) then
result:=(-1)
else
result:=1;
end;
end;

end; {compare}

I dont know if this is where the problem sits but I think so. If
someone could help me please.
Back to top
th0r1000
Guest





PostPosted: Mon Jan 22, 2007 4:42 am    Post subject: Re: Stringgrid date sorting not working correctly Reply with quote



Dont worry I got it right, I forgot to check my date format. Thanks guys
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.