Print Page | Close Window

Sort formula with string and date fields

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=8461
Printed Date: 04 May 2024 at 2:47am


Topic: Sort formula with string and date fields
Posted By: JHemauer
Subject: Sort formula with string and date fields
Date Posted: 24 Nov 2009 at 7:18am
New to the forum and hoping someone can help me. I've built a report that I can Group by Employee Name, Employee Schedule or the Schedule Start Time.
 
My problem is that the formula editor won't allow both string and date fields, so I had to convert the date field to a text field (using ToText), but now the report doesn't sort by time (as it now doesn't recognize that 1:00pm should come after 12:59pm. My formula is below, can anyone offer help?  
 
if {?SortOrder} = "C"
then {Employee.Entity_Name}
 
else if {?SortOrder} = "A"
then {EmployeeSchedule.barName}
 
else if {?SortOrder} = "T"
then ToText ({EmployeeSchedule.fromDateTime})
 
 



Replies:
Posted By: DBlank
Date Posted: 24 Nov 2009 at 8:04am
Since this is only needed for sorting foece the  toext(date) into a useful sorting format including military time use...
 
if {?SortOrder} = "C"
then {Employee.Entity_Name}
 
else if {?SortOrder} = "A"
then {EmployeeSchedule.barName}
 
else if {?SortOrder} = "T"
then ToText ({EmployeeSchedule.fromDateTime},'yyyyMMddHHmmss')


Posted By: JHemauer
Date Posted: 24 Nov 2009 at 8:12am
DBlank, thank you, that worked perfectly! I'm self-taught and it's the little things that kill me.
 
Much apprciated.



Print Page | Close Window