Print Page | Close Window

Trim Field

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=10251
Printed Date: 02 May 2024 at 9:23am


Topic: Trim Field
Posted By: btamulis
Subject: Trim Field
Date Posted: 15 Jun 2010 at 4:17am
I think this is fairly simple in Crystal -
 
My report has an item number (string field) that is always 15 characters long.
 
Example - 10.10.131.22500
 
On my report I want to truncate the first 3 characters (always).
 
Example - 10.131.22500
 
Any guidance would be appreciated........
 
Thanks in advance.......... 


-------------
Thanks to all who contribute to this forum!!!



Replies:
Posted By: kevlray
Date Posted: 15 Jun 2010 at 4:20am
You can use the right function to return the right most characters (12?).  Example: Right({String}, 12).  If you ever have a string that is not a fixed length, then you can use len to determine the lenght of the string first.  Example:  right({String}, len({String}) - 3).


Posted By: btamulis
Date Posted: 15 Jun 2010 at 5:16am
Worked like a champ!Clap
 
Thanks.........


-------------
Thanks to all who contribute to this forum!!!


Posted By: nsk74n
Date Posted: 10 Feb 2015 at 10:34am
I tried doing this and I get an error stating a string is required and last I checked it is a field name and I have that. Am missing something else?

Right({DriveMaster.DriveID},4)


Posted By: DBlank
Date Posted: 10 Feb 2015 at 11:03am
Likely it is a numeric field.
what are the some sample values and how do you want them displayed?


Posted By: nsk74n
Date Posted: 10 Feb 2015 at 11:14am
It is. Got past that. Now I need to get rid of the comma.


Posted By: kevlray
Date Posted: 10 Feb 2015 at 12:04pm
If it is a numeric field, then it is just a formatting option (look at your tool bar).  If it is a string, then try replace.


Posted By: DBlank
Date Posted: 11 Feb 2015 at 4:07am
if for some reason you chose to convert it to text you can format it during the conversion but as Kevlray indicates there are easy formatting options while keeping it numeric.
 
totext(number_field, x ,"")
the X is the number of decimal places you want
the "" indicates not to use the anything (e.g. a comma) as a seperator
 
or you can apply formatting with lead zero like this
totext(number_field,"00000.00")
 
quite a few options in the format process that are well explained in Crystal Help
 


Posted By: nsk74n
Date Posted: 11 Feb 2015 at 4:31am
Thanks. I will try that.



Print Page | Close Window