how to custom style the number format in crystal report - crystal-reports

Suppose I say I have number eg:89000000000 I need to format like 89,00,00,000.00 in this format of Indian numerical system as crores.

The following formula should work:
CStr({TableName.NumberColumnName}, "##,##,##,##,###.##"))
To explicitly specify the digit grouping character, add those parameters:
CStr({TableName.NumberColumnName}, "##,##,##,##,###.##", 2, ",")
(The digit grouping character depends on the system settings if not specified explicitly.)

Related

How do I remove the actual decimal from a numeric field that I'm converting to text? ex: 125.02 needs to be 12502

I'm creating an OCR line for our remits that our scanner will read. The scanner doesn't allow the '.' in the field - it assumes the last 2 digits are the decimal place values. I'm converting the field to to text but not sure how to remove the '.' and keep the decimal place values.
The most simple solution would be to create a Formula Field and use the Replace() function. The formula for your Formula Field would look like this:
StringVar myVariable;
myVariable := Replace({table.column}, ".", "");
myVariable;
This will search {table.column} for the first occurrence of a decimal and replace it with an empty string.
However, if your intent is to barcode the value, there may be a UFL available that could also do this for you. When creating barcodes, User Function Libraries are usually preferred because they have functions specifically designed to encode your barcode values. They aren't required though and you can always choose to manually encode barcode values manually with Formula Fields.

Kentico 9 form fields.. Is there a way to make a feild into a currency field only?

Have a form I am trying to build and even though I have a text box field that will work for users to enter a $ amount it would be nice to make it so that field only accepts numbers and keeps it in the $0.00 format. Seems like a simple thing but I cannot seem to find out how this would be done.
You need to specify the field as a decimal or double and define the precision (depending on what version you are using). The field should NOT be a text field but can use a textbox as the displaying control.
From an output standpoint, it will not automatically output $0.00, you have to format that based on the culture. There are several macros and functions within the API to do this.
Setup you control as followed
make the Data type a decimal number
in the Editing control settings click to show the Advanced section
in Filter set Type to Numbers and Custom
Add Valid characters your delimiter (, or .)
In the validation section add a rule for the minimum value to be 0.
The data type will enforce it to be a actual number.
You could also use as Validation a Regular expression setting something like:
^[$]?([0-9]{1,2})?,?([0-9]{3})?,?([0-9]{3})?(\.[0-9]{2})?[$]?$
which will allow a dollar sign prefix or suffix.

Struggling with dates formats, want YYYY-MM-DD

As an absolute beginner to SAS I quickly ran into problems with date formatting.
I have a dataset containing transaction with three types of dates: BUSDATE, SPOTDATE, MATURITY. Each transaction is represented on two lines, and I want BUSDATE and SPOTDATE from line 1 but MATURITY from line 2.
In the original set, the dates are in YYYY-MM-DD format.
DATA masterdata;
SET sourcedata(rename(BUSDATE=BUSDATE2 SPOTDATE=SPOTDATE2 MATURITY=MATURITY2));
BUSDATE=BUSDATE2;
SPOTDATE=SPOTDATE2;
IF TRANS_TYPE='Swap' THEN;
MATURITY=SPOTDATE;
RUN;
Problem is, this returns something like 17169 (which I guess is the number of days from a certain date).
How can I make it output in YYYY-MM-DD format - or is this approach wrong; should I first convert the date variables to some SAS date format?
if you have valid SAS dates, just add a FORMAT statement to your DATA STEP.
Format busdate spotdate maturity yymmdd10. ;
SAS dates are numeric variables. They represent the number of days since 1/1/1960. You use a FORMAT to display dates.
Adding to CarolinaJay's answer, you normally want to keep them as numeric format, since you can do math (like "# of days since date X") with them. However, if for some reason you need a character variable, you can do this:
date_As_char=put(datevar,YYMMDD10.);
Incidentally, YYMMDD10 will actually give you YYYY-MM-DD, as you asked for; if you want a different separator, see http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a000589916.htm (YYMMDDxw. format) - if you put a letter after the last D, for certain letters, you get a different separator. Like, YYMMDDn10. gives you no separator, or YYMMDDs10. gives you slashes. YYMMDDd10. gives you dashes, just like omitting the letter would. This concept also applies to MMDDYY formats, and I think a few others.

crystal reports - how to extract a date from string

Using Crystal Reports 2008, I need to extract a date from a text field. This date is usually in the format dd/mm/yy, but could also be entered as d/m/yy, dd/m/yyyy, etc.
This date could appear anywhere within the string.
At the moment I am relying on the fact that the date is placed at the end of the string, without a following fullstop, and using LEFT/RIGHT to extract each date part. These parts are then passed to another formula to create a full date:
Dim AllocationDate() as Date
If Not(IsNull({Command.Notes})) then
Formula = DateValue ((ToNumber ({#Year})), (ToNumber ({#Month})), (ToNumber ({#Day})))
However, if anyone uses a variation of format, adds a fullstop or more notes after the date the whole report keels over.
Is there any way I could extract this date by looking for a pattern? I'm guessing I could the use TRIM to get around the inconsistencies in format.
tyvmia
You may want to consider using a regular expression.
Crystal Reports doesn't have native support for regular expressions, so you'll need to add a UFL: crystal reports : is there a way to regex in crystal reports?
You should be able to adapt the pattern in this question for your needs: Javascript date regex DD/MM/YYYY
Finally, you can test the pattern on your text using regexpal.com.
** edit **
Create a SQL-expression field (Oracle 10 syntax) to extract date string and convert it to a date field:
// {%Allocation Date}
(
-- match date-like string, then convert to date type; is no dates are found, NULL is returned
TO_DATE( REGEXP_SUBSTR( TABLE.FIELD, '\d{1,2}\/\d{1,2}\/\d{2,4}',1 ,1), 'dd/mm/yyyy')
)
While you could
And, as a last resort, you can try converting the multi-line string into a long string by replacing the special characters that represent CR, LF, etc. Replacing them with spaces or another innocuous character, and then treat the resultant string as if it were just a regular string (with the date in the middle).
You would still have to make some assumptions to make this possible: ONE date per string, all special characters are known (or you have to test for all possible special characters), the date has SOME conformity to the format, etc.

Formatting a field using ToText in a Crystal Reports formula field

I'm trying to create a Crystal Reports formula field (to calculate the percentage change in a price) that will return "N/A" if a particular report field is null, but return a number to two decimal places using accounting format (negative numbers surrounded by parentheses) if it is not.
The closest I have been able to manage is this:
If IsNull({ValuationReport.YestPrice}) Then
'N/A'
Else
ToText({#Price}/{ValuationReport.YestPrice}*100-100, '###.00', 2)
However this represents negative numbers using a negative sign, not parentheses.
I tried format strings like '###.00;(###.00)' and '(###.00)' but these were rejected as invalid. How can I achieve my goal?
I think you are looking for ToText(CCur(#Price}/{ValuationReport.YestPrice}*100-100))
You can use CCur to convert numbers or string to Curency formats. CCur(number) or CCur(string)
I think this may be what you are looking for,
Replace (ToText(CCur({field})),"$" , "") that will give the parentheses for negative numbers
It is a little hacky, but I'm not sure CR is very kind in the ways of formatting
if(isnull({uspRptMonthlyGasRevenueByGas;1.YearTotal})) = true then
"nd"
else
totext({uspRptMonthlyGasRevenueByGas;1.YearTotal},'###.00')
The above logic should be what you are looking for.