Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Report sort Post Reply Post New Topic
Author Message
colman1212
Newbie
Newbie


Joined: 08 Jul 2010
Location: Ireland
Online Status: Offline
Posts: 36
Quote colman1212 Replybullet Topic: Report sort
     Posted: 22 Sep 2010 at 4:49am
Ok so I'm taking in a parameter called 'SortField' and trying to sort the report based on that. The problem is when I try to sort on Create date, i get an error saying 'string is required here'. so I then have to put quotes around it. When I put the quotes around it, it looks at it like text and doesn't actually sort it correctly. Anyone know how I can correct this?!
 
 
if {?SortField}='Summary' then {CALL_.CALSUMMARY}
else if {?SortField}='Status' then {CALL.STATUS}
else if {?SortField}='Incident Number' then {CALL.CALLID}
else if {?SortField}='Create Date' then '{@CreateDate}'
 
 
 
---------------
 
CreateDate formula is: HelpDeskDateFieldToDate ({CALL.CALLDAT})
 
 
 
 
IP IP Logged
saoco77
Senior Member
Senior Member


Joined: 26 Jun 2007
Online Status: Offline
Posts: 104
Quote saoco77 Replybullet Posted: 22 Sep 2010 at 5:20am
I'm not sure if this the correct solution
I'm think you want to use the totext function rather than put quotes around the formula.

Something like this might work:

if {?SortField}='Summary' then {CALL_.CALSUMMARY}
else if {?SortField}='Status' then {CALL.STATUS}
else if {?SortField}='Incident Number' then {CALL.CALLID}
else if {?SortField}='Create Date' then totext({@CreateDate})
IP IP Logged
colman1212
Newbie
Newbie


Joined: 08 Jul 2010
Location: Ireland
Online Status: Offline
Posts: 36
Quote colman1212 Replybullet Posted: 22 Sep 2010 at 5:29am
Yeah i've tried using toText but it does the exact same thing as using the quotes. they just don't seem to sort it properly.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Sep 2010 at 5:40am
Not sure so look closely but I but this might work:
 
if {?SortField}='Summary' then {CALL_.CALSUMMARY}
else if {?SortField}='Status' then {CALL.STATUS}
else if {?SortField}='Incident Number' then {CALL.CALLID}
else if {?SortField}='Create Date' then totext({CALL.CALLDAT},'yyyyMMdd')
IP IP Logged
colman1212
Newbie
Newbie


Joined: 08 Jul 2010
Location: Ireland
Online Status: Offline
Posts: 36
Quote colman1212 Replybullet Posted: 22 Sep 2010 at 5:46am
Nope, Sorry....I get bad number string formatting error.......
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Sep 2010 at 5:48am

what format is the data stored for date field in the DB?

IP IP Logged
colman1212
Newbie
Newbie


Joined: 08 Jul 2010
Location: Ireland
Online Status: Offline
Posts: 36
Quote colman1212 Replybullet Posted: 22 Sep 2010 at 5:51am
not sure what its called but 131,728,411.00 becomes 27/04/2010 using the below formula.
 
HelpDeskDateFieldToDate ({CALL.CALLDAT})
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 22 Sep 2010 at 5:55am

I assumed the original field was a date not numeric.

so your @createdate uses a function to convert the number to a date.
try:
if {?SortField}='Summary' then {CALL_.CALSUMMARY}
else if {?SortField}='Status' then {CALL.STATUS}
else if {?SortField}='Incident Number' then {CALL.CALLID}
else if {?SortField}='Create Date' then totext({@CreateDate},'yyyyMMdd')
IP IP Logged
colman1212
Newbie
Newbie


Joined: 08 Jul 2010
Location: Ireland
Online Status: Offline
Posts: 36
Quote colman1212 Replybullet Posted: 22 Sep 2010 at 6:04am
Great, Thanks a million, much appreciated!
IP IP Logged
Printable version Printable version

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