Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Concatenating strings, Date and Number fields Post Reply Post New Topic
Author Message
jim_rs300
Newbie
Newbie
Avatar

Joined: 01 Oct 2007
Online Status: Offline
Posts: 2
Quote jim_rs300 Replybullet Topic: Concatenating strings, Date and Number fields
    Posted: 01 Oct 2007 at 10:44am
Hi Everyone,
 
I just wondered if it was possible to concatenate Strings, DateTime and Number fields into a single string?
 
I have found how to concatenate Numbers & strings but not dates.  Would the only way be to use a separate formula to convert the DateTime into a string and then use that in the concatenation or is there an easier way?
 
Thanks in advance!
 
James
IP IP Logged
jkwrpc
Senior Member
Senior Member


Joined: 19 Jun 2007
Location: United States
Online Status: Offline
Posts: 432
Quote jkwrpc Replybullet Posted: 01 Oct 2007 at 11:50am
I would simply create the formula and then use the CStr function with the date field. That will change it to a string and you can take it from there.
 
CStr({nameofDateField})
 
Hope this helps.
 
Regards,
 
John W.
 
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 01 Oct 2007 at 2:55pm
If you need to concatenate data to use for grouping or sorting, you'll have to format the numbers and dates.
 
I usually do this with dates:
 
to_text({datefield}, 'yyyyMMdd')
 
And this with numbers:
 
right('000'+{numberfield}, 3)
 
(This assumes the number's max value is 999 and that it can't be negative.  You can modify it for larger numbers.)
 
-Dell
 
IP IP Logged
wattsjr
Groupie
Groupie
Avatar

Joined: 25 Jun 2007
Location: United States
Online Status: Offline
Posts: 51
Quote wattsjr Replybullet Posted: 02 Oct 2007 at 8:48am
Hi James -
 
Based on the others responses, I may not have a correct understanding of what it is that you are trying to do, but you might try the following:
 
1.  Create, or insert, a text object into your report.
2. Then right-click on the text object and select "Edit Text Object"
3. Insert (drag & drop) the fields that you want to concatenate.
 
As a test I created a text object containing the following:
 
Text Label + String + Text Label + Date + Text Label + Number (see below)
 
Customer: {CustomerName} was created on: {DateCreated} with ID#: {CustomerID}
 
The text object displayed everything correctly, and all of the parts are fully formatable, so you can format the Name, Date and Number any way that you want them.
 
Is this what you wanted to do?
 
Regards,
 
-jrw
IP IP Logged
jim_rs300
Newbie
Newbie
Avatar

Joined: 01 Oct 2007
Online Status: Offline
Posts: 2
Quote jim_rs300 Replybullet Posted: 02 Oct 2007 at 9:14am
Cheers people.  Advice worked a treat.
 
James
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.008 seconds.