Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: sorting dates Post Reply Post New Topic
Author Message
ricky_vegas
Newbie
Newbie


Joined: 03 Jan 2008
Location: United States
Online Status: Offline
Posts: 15
Quote ricky_vegas Replybullet Topic: sorting dates
     Posted: 03 Jan 2008 at 9:53am
I'm pulling data from ms sql 2005. The field data type for the DATE_PROMISED is "char".
In Crystal XI I created two parameter fields: Start Date and End Date (both as string).
Then I created a Formula Field: DateHeader:
"From: " & CDate({?Start Date}) & " To" & CDate({?End Date})
Last, I grouped by JC.10.DATE_PROMISED
 
When I run the report, the data is grouped properly withing the year but not withing the period (11/14/07 to 04/30/08). For example, my report starts with
01/02/08
01/03/08
02/07/08
04/02/08
11/14/07
12/05/07
12/31/07
 
What am I doing wrong? Thanks for your help.
Rick
IP IP Logged
Lugh
Senior Member
Senior Member
Avatar

Joined: 14 Nov 2007
Online Status: Offline
Posts: 377
Quote Lugh Replybullet Posted: 03 Jan 2008 at 11:07am
DATE_PROMISED is still a string value.  It can't be grouped into periods, because strings don't come in periods (though periods do come in strings!  LOL ).

If at all possible, I actually recommend doing the data conversion on the SQL side.  If you are able to alter the view/procedure you are using, add a field to convert DATE_PROMISED to an actual date.  If not, use the Add Command feature when building your data source to do so.

If that is not possible, you'll need to do the conversion in Crystal.  Create a formula, say @PromDate (because everyone needs one of those).  It should look like:

CDate({JC.10.DATE_PROMISED})

That's it.  Now, do your grouping on @PromDate.  It should work correctly now.

IP IP Logged
ricky_vegas
Newbie
Newbie


Joined: 03 Jan 2008
Location: United States
Online Status: Offline
Posts: 15
Quote ricky_vegas Replybullet Posted: 03 Jan 2008 at 12:24pm

Lugh,

thanks so much. I created a new formula (@PromDate) and I grouped on @PromDate and I SOLVED the problem. thanks again for your precious help.
 
Maybe one of these days I'll be able to help someone too. :-)
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