Hi Friends,
I have a decimal field. I have to seperate the integer part and decimal part seperately and store in string field.
Decimal Field Value: 62134.1818515
The output I expect is:
IntegerPart : 62134
DecimalPart : 18
Note: I need not round this to any position.
Datatype: IntegerPart, DecimalPart - Code[20]
The code I wrote is:
IntegerPart := FORMAT(DecimalFieldValue,0,'<Integer>');
DecimalPart:= FORMAT(DecimalFieldValue,0,'<Decimals,2>');
I am getting the output as: 62134**
Thats is IntegerPart : 62134
DecimalPart : **
Why it is so? Can anyone help me on this?
Thanks in advance
Aravindh R.
Comments
DecimalPart:= FORMAT(DecimalFieldValue,0,'<Decimals,8>');
DecimalPart := COPYSTR(DecimalPart,2,2);
how about this:
Will this work for you?
Regards,
Willy
The <Precision,2:> part is to assure you get digits and no blanks within your two needed characters (for values of DecimalFieldValue with one or zero digits) This would otherwise lead to probably unexpected results: 3.1 -> '1' (or '1 '); 3.101 -> '10'. If you want to get blanks instead e.g. for 3.1 DecimalPart = '1 ', then you need to leave out that part of the format string and probably change DELCHR to only delete blanks at the beginning of the string and maybe add another DELCHR to delete '0' from the end.
Simple solution if you don't have to consider anything else:
Complex solution:
Both not tested...