Show date after split it in Crystal Reports - date

How can I concatenate this a date in Crystal Reports after split it.
I have this formula:
global numberVar d :=toNumber(mid({BAQReportParameter.Option01},4,2));
global numberVar m:= toNumber(left({BAQReportParameter.Option01},2));
global numberVar y:= toNumber(right({BAQReportParameter.Option01},4));
Global stringVar datetxt;
datetext := ToText(d) + "/" + ToText(m) +"/" + ToText(y);
but it has an error.

global stringvar d :=(mid({BAQReportParameter.Option01},4,2));
global stringvar m:= (left({BAQReportParameter.Option01},2));
global stringvar y:= (right({BAQReportParameter.Option01},4));
Global stringVar datetxt:= ToText(d + "/" + m +"/" + y);
Do this simple changes it will work!!

Related

How to Print specific row in each page Crystal Report

whileprintingrecords;
global numbervar DetailCount;
DetailCount := DetailCount + 1;
Global numbervar DetailCount;
DetailCount Mod 10 = 0
IF Remainder (RecordNumber, 8) = 0 THEN
TRUE
ELSE
FALSE
IF Remainder (RecordNumber, 8) = 0 and not OnLastRecord THEN
TRUE
ELSE
FALSE
i have try this codes but not get it.
Please describe better what you would like to print on each page.
I'm guessing you would like to print a summary that would only show the sum of one printed page.
You need 3 formulas:
sum_pagesum (should be placed in the details-section as hidden field):
whileprintingrecords;
numbervar pagesum;
pagesum:= pagesum + {WHATEVER};
current_pagesum (should be placed in the page-footer-section, this prints your sum):
whileprintingrecords;
numbervar pagesum;
pagesum;
reset_pagesum (should be placed in the page-footer-section after the current_pagesum)
whileprintingrecords;
numbervar pagesum;
pagesum:= 0;

Convert Number to words in Crystal Report using Crystal Syntax

I'm working on the task to convert the number to words using Crystal Report and Crystal syntax as well.
I did well for any amount <100K with the code below but face the problem with amount >100K (in VN currency, we even convert hunderds billions, not only 10K or millions). Could some one helps me to find the way to handle this issue to convert any amount to words .
Thank you in advance for any help from you.
//the array value is the wording of number in EN Zero, One, Two, Three...
local stringvar array Array_Items:= ["không","một","hai","ba","bốn","năm","sáu","bẩy","tám","chín"];
local numbervar x;
local numbervar z;
local stringvar strcuaso;
z:=10000;
local numbervar s10k;
local stringvar strs10k;
local numbervar s1k;
local stringvar strs1k;
local stringvar th;
local numbervar stram;
local stringvar strstram;
local numbervar schuc;
local stringvar strschuc;
local numbervar sdonvi;
local stringvar strsdonvi;
local stringvar a;
x:=50031;
strcuaso:=totext(x,2,"");
s10k:=tonumber(left(strcuaso,1));
s1k:=tonumber(mid(strcuaso,2,1));
if((s10k=1)and(s1k=0))then
strs10k:="mười";
if((s10k=1)and(s1k=0))then
strs1k:="nghìn";
if((s10k>1)and(s1k=0))then
strs10k:=totext(Array_Items[s10k+1])+" mươi ";
if((s10k>1)and(s1k=0))then
strs1k:="nghìn";
if((s10k=1)and(s1k>=1))then
strs10k:="mười ";
if((s10k=1)and(s1k>=1))then
strs1k:=totext(Array_Items[s1k+1])+" nghìn ";
if((s10k>1)and(s1k=1))then
strs10k:=totext(Array_Items[s10k+1])+ " mươi ";
if((s10k>1)and(s1k=1))then
strs1k:=" mốt nghìn ";
if(s10k>1)and(s1k>1)then
strs10k:=totext(Array_Items[s10k+1])+ " mươi ";
if(s10k>1)and(s1k>1)then
strs1k:=totext(Array_Items[s1k+1])+" nghìn ";
stram:=tonumber(mid(strcuaso,3,1));
schuc:=tonumber(mid(strcuaso,4,1));
sdonvi:=tonumber(mid(strcuaso,5,1));
strstram:=" "+totext(Array_Items[stram+1])+" trăm ";
if((schuc=0)AND(sdonvi=0))then
th:="A" ;
if((schuc=0)AND(sdonvi>=1))then
th:="B";
if((schuc=1)and(sdonvi>0))then
th:="C1";
if((schuc=1)and(sdonvi=0))then
th:="C2";
if((schuc>1)and(sdonvi=0))then
th:="D";
if((schuc>1)and(sdonvi=1))then
th:="E"; //strsdonvi="mốt";
if((schuc>1)and(sdonvi>1))then
strsdonvi:=totext(Array_Items[sdonvi+1])
th:="F";
if(th="A")then
strschuc:="";
if(th="A")then
strsdonvi:="";
if(th="B")then
strschuc:="";
if(th="B")then
strsdonvi:=" linh " +totext(Array_Items[sdonvi+1]);
if(th="C1")then
strschuc:="mười ";
if(th="C1")then
strsdonvi:=totext(Array_Items[sdonvi+1]);
if(th="C2")then
strschuc:="mười";
if(th="C2")then
strsdonvi:="";
if(th="D")then
strschuc:=totext(Array_Items[schuc+1])+" mươi " ;
if(th="D")then
strsdonvi:="";
if(th="E")then
strschuc:=totext(Array_Items[schuc+1])+" mươi " ;
if(th="E")then
strsdonvi:=" mốt ";
if(th="F")then
strschuc:=totext(Array_Items[schuc+1])+" mươi";
if(th="F")then
strsdonvi:=totext(Array_Items[sdonvi+1]);
if(x=z)then
a:="Mười nghìn VND"
else
a:=ProperCase(strs10k)+strs1k+strstram+strschuc+strsdonvi+" VND ";

crystal report - if else statement when array is declared: string length error

I'm a noob in Crystal Report.
I'm getting String length is less than 0 or not an integer error.
on left({ORDERCHECKVIEW.LOTNUMBER},InStrRev ({ORDERCHECKVIEW.LOTNUMBER},"-" )-1)
of the code below:
local StringVar mDate;
local StringVar mMonth;
local StringVar mDay;
local StringVar mYear;
if {ORDERCHECKVIEW.LOTNUMBER} = 'N/A'
then 'N/A'
else
mDate:= left({ORDERCHECKVIEW.LOTNUMBER},InStrRev ({ORDERCHECKVIEW.LOTNUMBER},"-" )-1);
mMonth:= left(mDate,2);
mDay := Mid (mDate,4 ,2 );
mYear := totext(2010 + CDbl (right(mDate,InStr(StrReverse(left({ORDERCHECKVIEW.LOTNUMBER},InStrRev ({ORDERCHECKVIEW.LOTNUMBER},"-" )-1)),"-") -1 )),0,""); // transform 2017
cDate(cDbl(mYear),cDbl(mMonth),cDbl(mDay));
cDate(cDbl(mYear),cDbl(mMonth),cDbl(mDay));
Can anyone please explain what's wrong? I don't think my if-else statement is wrong..
FYI, I have previously asked a question and this question is a follow-up:
(Advanced conversion of a single number to year, along with hyphen)
compounded if-else
local StringVar mDate;
local StringVar mMonth;
local StringVar mDay;
local StringVar mYear;
if {ORDERCHECKVIEW.LOTNUMBER} = "N/A"
then "N/A"
else
(
mDate:= left({ORDERCHECKVIEW.LOTNUMBER},InStrRev ({ORDERCHECKVIEW.LOTNUMBER},"-" )-1);
mMonth:= left(mDate,2);
mDay := Mid (mDate,4 ,2 );
mYear := totext(2010 + CDbl (right(mDate,InStr(StrReverse(left({ORDERCHECKVIEW.LOTNUMBER},InStrRev ({ORDERCHECKVIEW.LOTNUMBER},"-" )-1)),"-") -1 )),0,""); // transform 2017
// cDate(cDbl(mYear),cDbl(mMonth),cDbl(mDay));
ToText(cDate(cDbl(mYear),cDbl(mMonth),cDbl(mDay)),"MM/dd/yyyy") ;
)

Crystal Reports Prevent global variables from resetting on new page

Is there any way to prevent the resetting of variables on a new page?
In GH2 I initialize the following variable:
WhilePrintingRecords;
Global NumberVar RCountDaysInDenominator := 0;
In GF3:
EvaluateAfter ({#IsEndExamPopulated});
if {#IsEndExamPopulated} = True
then
NumberVar RCountDaysInDenominator := NumberVar RCountDaysInDenominator + 1
else
NumberVar RCountDaysInDenominator := NumberVar RCountDaysInDenominator + 0;
I didn't realize that when a single GF3 spans many pages, these variables reset.
Any suggestions? Thanks in advance!

String is Not Numeric

Having an issue when attempting to run a Mod formula against a field. I keep receiving the error "String is Not Numeric" and so far I have not been able to get ToNumber to correctly format the field. The field is being generated by adding a static value and three fields that have been padded. Any help would be appreciated.
Combines fields and pads
StringVar strMICR;
StringVar strMICRLINE;
strMICRLINE := Chr(13) & "0603250694";
strMICRLINE := strMICRLINE & Right("000000" & Trim(Split({CUST.C_ID_ALPHA},"-")[1]),6);
strMICRLINE := strMICRLINE & Right("00000000" & ToText({STMT.STMT_NUMBER},0,""),8);
strMICRLINE := strMICRLINE & Right("0000000000" & Replace(ToText({#Total},2,""),".",""),10);
//Uncomment below to test Mod10 Check-digit
//strMICR := mod10("0603250694084469108961440000127874");
//IF NumericText (strMICRLINE)
//THEN ToNumber (strMICRLINE);
Mod10 (strMICRLINE);
MOD10 Function
Function (StringVar input_number)
input_number := replace(input_number, " ", "");
numbervar i := length(input_number);
numbervar sum_val := 0;
stringvar position := "odd";
do (
if position = "odd" then (
sum_val := sum_val + 3*tonumber(input_number[i]);
position := "even" )
else (
sum_val := sum_val + tonumber(input_number[i]);
position := "odd" )
;
i := i-1
) while i > 0;
numbervar remainder_val := Remainder(sum_val, 10);
numbervar check_digit := if remainder_val = 0 then 0 else (10-remainder_val) ;
input_number + ToText(check_digit, 0)
You're attempting to call toNumber() on a string that is not numeric and therefore can't be converted. You need to strip all non-numeric characters out of your string first.
//Formula sample to strip non-numeric characters
local stringvar input := "78906-adf0asdf-234";
local stringvar output;
local numbervar i;
for i:=1 to length(input) do
if numerictext(input[i]) then output:=output&input[i];
output
Then I would highly suggest you use the built in mod function instead of rolling your own.
toNumber({#NumericTextOnly}) mod 10