In all forms of development there are times when you need to convert
data types for use in formulas. In Business Objects Crystal Reports, I
often use data with labels control to display totals in my report
footers. To do this in my SalesLogix Reports, I often have to convert
the total from a double to a string. For our benefit Crystal Reports
offers many conversions functions.
I found most of the information for this post in the Crystal help.
To view Help on these functions all you have to do is highlight the
function of interest in the function tree control and select the ?
button in the Formula Workshop tool bar.
The Boolean - Labeled CBool - is only used with numbers or currency,
This action returns a true if the referenced field is anything but 0,
if it is 0 then it returns a false. The syntax looks something like
this:
CBool ({OPPORTUNITY.SALESPOTENTIAL}) would return True or False
Currency - Labeled CCur - converts number, currency or string values
to a currency. This action returns a currency value. So instead of
formatting a field to display a currency you could just use this
function through a formula field. The syntax looks something like
this:
CCur({OPPORTUNITY.SALESPOTENTIAL}) returns $327,323.00
Date and Time - Labeled CDateTime, CDate, or CTime - all three will
convert DateTime, number or string values to and return a Date and/or
Time. Here is some example syntax:
CDate({OPPORTUNITY.CREATEDATE}) returns 2/26/2009
CTime({OPPORTUNITY.CREATEDATE}) returns 11:47:21 PM
CDateTime (2009,10 ,18, 13, 55, 21) returns 10/18/2009 1:55:21PM
String - Labeled CStr, Basically converts any other data type to a string value. Basic syntax looks something like this.
"The Total Sales Potential for this Opportunity is $" + CStr ({OPPORTUNITY.SALESPOTENTIAL})
Would return
The Total Sales Potential for this Opportunity is $327,323.00
I hope this blog is of help to someone.
You can benefit from this blog by downloading our many re-worked SalesLogix Crystal Reports, see a list by following this link and thanks for reading.
No comments:
Post a Comment