removing decimals in crystal reports for number field - crystal-reports

I have a field year which is string type coming from db side.So I converted that to number and adding 1 more year to that to show like this:
Year:2014-2015
Below is the formula.
'Year' & ':' & tonumber({FocusOnCustomer.YEAR})&'-'&(tonumber({FocusOnCustomer.YEAR})+1)
Everything is working fine in designer.But when I view the report in cr viewer I am getting data like this.
2,014.00-2,015.00
I want to remove decimals and comas

Try:
ToText( ToNumber({FocusOnCustomer.YEAR}), "#")

Right-click on the field or formula
Select Format Field
On the Number tab, choose the format to use from the list or click Customize to create a custom format.
Click OK
Website Link

Related

Decimals dont show and adds 000

I have a string filed in my crystal report with a value of 696 000.00. But I want to be displayed as 6,960,00 in my report. I am using below formula but that's not working. Any ideas?
the Normal value befor I add the formua is 6960.
ToText( ToNumber({Fakturalinje.ItemDescription2}))
You have 2 ways...
One right click on the field and go to format and select required option.
Second way
ToText({Fakturalinje.ItemDescription2},'#')
Format window will be like this.

Crystal Reports Parameter Input dialog box changing the date format

When I generate a report that expects two date parameters, I first see the dialog box titled 'Enter Values' and the dialog box contains two text boxes with its own date picker widget. However, once I pick a date and click 'OK', the date is formatted as 'dd/MM/yyyy'. Does anyone know if it is possible to configure the report in a way so that the date format matches Windows system locale short date format? Instead of just defaulting to dd/MM/yyyy?
Thanks!
The date format for the parameter can't be changed, at least as far as I know. If you want the date displayed in a different format, you can always create a formula:
"From : " & ToText(Minimum({?date}), "M-d-yy") &
" To :" & ToText(Maximum({?date}), "M-d-yy")
Or you can go into the File menu, click on Options and under the Fields tab, there is a button for Date. Click on that and you can choose the format under the Date tab. This is for CR 2008, so it may be slightly different for CR XI.
If You are trying to filter in your SQL on date range field then you can add castings on dates. Like
datarangeField between cast({?Start Date} as date format 'm-d-yy')
AND cast({?End Date} as date format 'm-d-yy')
Also, you are required to add these (Start Date and End Date) in your SQL Parameters during Adding the query.
For display you can use formulas and format field options.

How to remove comma from crystal report string and from integer field

How can I remove the comma (,) from crystal report fields?
I have a field name "year" which is having a value of 2012, but when I show that value in crystal report it includes a comma, becoming 2,012.
How can I show only 2012?
In the crystal report designer view:
Right mouse click on that field, and select Format object. Select Custom Style in the Style list, and click Customize. Untick Thousands Separator, and any other unwanted formatting.
Failing that, you could try selecting the field and deleting the "," value from the property ThousandSeperator in your properties window.
try this
for formula
ToText( ToNumber({variable1}), "#" )
Try below code,
Replace (ToText ({Tablename.Year_Field}, 0),"," ,"" )
I'm just guessing but I believe you have embedded your field name into another object such as a text field.
If this is the case, double click your text box in the design view, then select your text field you are having issues with. Right click and select "Text Formatting", under the Font tab click the 'Format Formula Editor' button (the one with the X-2) to the right of the Font drop down menu. Now all you have to do is close the formula editor, then cancel the Text Format window. NOW when you right click on your year field again you will have a new option to Format the field which was previously grayed out.
Alternatively, you can remove your year field from any other object it is nested in. This will give you access to all formatting options.
NumberVar cRed;
ToText (cRed,"#")
OR
ToText({some numeric field value},"#")
The "#" has to be enclosed in parenthesis, single or double.

Add date to to Crystal Report Text Object

I have a Text Object on my report which is contains some text. What I'd like to do is add a date to the text object that will alaways show the current date. I've tried using a date field, but it is near impossible to line it up correctly.
Any ideas on how to do this? I've been told that there is a way to do this using something like &[], but I can't figure out how.
Thanks!
You can edit the date inline, double click on the text field then select the date text, you can now click on the formatting button on the toolbar and setup the date format.
You can drag any field, including special ones (Print Date for example) into text object - it will line up without problems.

Formatting data in Crystal Reports

I have a field which is a Double. For display on a the report, if that value is negative, then I need to reverse the number by multiplying it by -1. The result should be formatted like this: "(1,000)" (notice no "-" sign). How can I do this in Crystal? I was using a Display String formula to try to do this since the "Reverse sign for display" option doesn't work for me (because it needs to be a formula for other reasons).
So far I have:
if {columnName} < 0 then
"(" & ToText({columnName}, "#,###", 0) & ")"
else
"(" & ToText({columnName} * -1, "#,###", 0) & ")"
But this gives me something like this: "(-6,500)", and I need to get rid of that pesky minus sign.
Edit:
I implemented a formula field like this:
-Abs({columnName})
Then selected the format that looks like (1,234) from the format list as Craig answered below.
Crystal Reports supports 'accounting' formatting w/o much effort:
right click field, select Format Field...
select Number tab (if not selected)
choose the style that resembles '(1,123.00)'
** edit **
You can also apply this formatting to a formula field.
I have accomplished my requirement this way< I have added a formula and assigned sum of the required field then I set its Format (12,34.00) also i have removed Dollar sign.
Formula = replace(totext(Sum({myfield}) * -1),"$","")
I have face same pro blame but it OS specific . ON windows xp no any formatting problem but above xp this issue face. Use following formula in Display Formula after removing all formatting .
Replace(Replace(Replace(ToText (CurrentFieldValue, "##,##,##,##0.00", 2),"$",""),"-",""),",","")