I am working on a crystal report, can someone guide me how i can convert currency to words in this format;
(1,502,000.50) One million five hundred and two thousand naira and fifty kobo Only. i have tried:
numberVar x := {#summAmt} - int ({#summAmt});
if x = 0 then
propercase (toWords (int({#summAmt}),0)+ ' Naira Only')
else
propercase (toWords (int({#summAmt}),0)+ ' Naira, and ' + toWords ((x * 100),0) + ' Kobo')
To go around this, you will need 2 formulas; create the one i posted earlier, then create then create another formula with the following code:
numberVar x := {#summAmt} - int ({#summAmt});
if x > 0 then
replace ({#convertWords},"Hundred ","Hundred and " )
else
{#convertWords}
{#convertWords} is the name of my first formula and #summAmt is the name of the field i am converting.
Related
How to display full name in short form like S.M.John in Crystal Reports.
Ex: Database value = Sammual Mbark John.
Need to display => S.M.John
Thank You
Considering your full name can have 2, 3, n names, I think this formula will do the job:
Stringvar result := "";
Local Numbervar i;
Stringvar Array output:= Split({Your.Field}, ' ');
for i := 1 to ubound(output) do (
if i <> ubound(output) then
result := result + left(output[i], 1) + "."
else
result := result + output[i]
);
result
Example and results:
1) "This Is My Test Name" will be "T.I.M.T.Name"
2) "Kurt Donald Cobain" will be "K.D.Cobain"
3) "Barack Hussein Obama" will be "B.H.Obama"
4) "Sammual Mbark John" will be "S.M.John"
I have a report that sums data and I am trying to modify it. I am trying to break out the totals by week by machine instead of one grand total by machine. Example of the calculations look like the following:
numberVar x := Sum ({WorkCntrSummary.Downtime_DurationInMinutes_Category0}, {WorkCntrSummary.Criteria_MachineID});
numberVar xh := Truncate(Round(x)/60);
numberVar xm := Round(x) mod 60;
if xh >= 1 then
ToText (xh, 0) + "h " + ToText (xm, 0) + "m"
else
ToText (xm, 0) + "m"
I am trying to change the 1st line where it is summing the field by MachineID. I want to sum it on the MachineID and also on a different group I added to the report which is a date field grouped by week. I am at a loss as to how to change that sum to add the date field by week to it. I tried changing it to the following, which doesn't do anything with grouping by week.
numberVar x := Sum ({WorkCntrSummary.Downtime_DurationInMinutes_Category0}, {WorkCntrSummary.Criteria_MachineID},{WorkCntrSummary.Criteria_StartDateTime});
numberVar xh := Truncate(Round(x)/60);
numberVar xm := Round(x) mod 60;
if xh >= 1 then
ToText (xh, 0) + "h " + ToText (xm, 0) + "m"
else
ToText (xm, 0) + "m"
But I get an error group condition must be a string.
Any help would be much appreciated.
Thanks!
Change
Sum ({WorkCntrSummary.Downtime_DurationInMinutes_Category0}, {WorkCntrSummary.Criteria_MachineID},{WorkCntrSummary.Criteria_StartDateTime})
to
Sum ({WorkCntrSummary.Downtime_DurationInMinutes_Category0}, {WorkCntrSummary.Criteria_StartDateTime})
In Crystal, the 2nd argument is what you group on. No need to chain all the grouping elements.
Hi I'm new in Crystal Reports, I'm using Crystal Reports 2008 and I would like to know if how can I remove the alphabet characters in string and only the numbers will remain. Is there function for this?
example: Point 231 / Point 323 / USP 342
output: 231 / 323 / 342
Thanks,
Captain16
Use the following formula
stringvar str;
stringvar str1;
numbervar counter;
numbervar leng;
leng := len({Your_Field});
if leng>0 then
(
for counter := 1 to leng do
(
If (Mid({Your_Field}, counter, 1)) in "a" to "z" Then
(
str1:=str1 + Mid({Your_Field}, counter, 1)
)
else
(
str := str + Mid({Your_Field}, counter, 1)
)
);
str
)
Here the str will get the non-alphabets and str1 will get you only the alphabets from the given string. {Your_Field} can be your field or parameter which contains the string. And by printing str alphabets can be removed...
231 / 323 / 342 this is the output I'm getting for your given input !
Hope this helps, Try and get back with results !
Sorry, I can't comment on Hariharan Anbazhagan's code (I don't have enough reputation it seems). It's good code but I would add LCASE to catch all the captial letters.
If LCASE(Mid({?sample}, counter, 1)) in "a" to "z" Then
There's also a IsNumeric() function if you want to identify just the numbers.
Let assume
x = 1001
Now I am inputting x to my code and generating y in the following order:
Length of 1001 is 4 so starting from the last number
i.e. 1(number) * 4(position of number) & 0 * 3 & 0 * 2 & 1 * 1 that gives a new number 4001
Another eg. 1234 gives 16941
In crystal I am creating a formual as follows:
stringvar tmp_EventNo;
stringvar tmp_Password;
numbervar i;
numbervar m_password;
tmp_EventNo = Trim(ToText({GR_EVENT.event_number}));
For i := Len(tmp_EventNo) To 1 Step -1 Do
(
tmp_PassWord = tmp_PassWord & Trim(ToText(Val(Mid(tmp_EventNo, i, 1)) + i));
);
m_Password = Val(tmp_PassWord);
m_password
But it doesnt seem to work. Just results in 0.00
Please help thanks in advance
Nice easy one- you will kick yourself :)
In Crystal = is used for evaluation. := is used for assignment.]
There were a few other issues with the code so i tweaked it for you:
stringvar tmp_EventNo;
stringvar tmp_Password;
numbervar i;
numbervar m_password;
tmp_EventNo := Trim(ToText({GR_EVENT.event_number}, 0, ''));
For i := Len(tmp_EventNo) To 1 Step -1 Do
(
tmp_PassWord := tmp_PassWord & Trim(ToText(Val(Mid(tmp_EventNo, i, 1)) * i,0));
);
m_Password := Val(tmp_PassWord);
tmp_PassWord;
My goal is the discern whether the domain has a subdomain or not by counting the number of periods there are in the domain name. If it has 2 periods, there is obviously a subdomain.
I have the following crystal reports formula written in crystal syntax
local numbervar count :=0;
Local numbervar strLen := length({?domain});
local stringvar c := {?domain};
local numbervar i;
local numbervar pos2 :=0;
for i:=1 to strLen do
( if Mid({?domain}, i, 1) = "." then
(
count := count + 1;
if count = 2 then (
pos2 := i
);
);
);
if count > 1 then
left({?domain}, pos2)
else
left({?domain},instr({?domain}, ".")-1)
any ideas? hopefully this is something my tired eyes are just glazing over.
UPDATE: here is the weird thing that happens.
If I add "+ totext(pos2)
if count > 1 then
left({?domain}, pos2) + totext(pos2)
else
left({?domain},instr({?domain}, ".")-1)
it outputs correctly subdomain.domain with the .com removed
if i run it without the totext(pos2)
if count > 1 then
left({?domain}, pos2)
else
left({?domain},instr({?domain}, ".")-1)
it only shows the subdomain part of subdomain.domain.com
Any ideas why?
Should there be a final ; on the last line?
Alternatively, have you considered making the entire formula something like:
Left({?domain},InStrRev({?domain}, ".")-1)