Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Report Design
Message Icon Topic: Type conversion and extracting part of value Post Reply Post New Topic
Author Message
Gurojee
Newbie
Newbie


Joined: 23 Feb 2009
Location: India
Online Status: Offline
Posts: 6
Quote Gurojee Replybullet Topic: Type conversion and extracting part of value
    Posted: 14 Jul 2010 at 4:28pm
Hi,

I want to extract a part of values from the decimal field. I want to covert the decimal value i.e. "0.00010000" to string and extract the value from left untill it is not whole number. for example, in the above value I want to get out "0.0001" from left and the rest of 0s on the right side on 1 should be omitted on the report. Similarly, if the value in the database field is "0.02000000" then I just want to extract the value "0.02" and rest of 0s should not be displayed on the report. I got the below code which works fine but it does returns NO VALUE if the value in the database field is "1.00000000". I want it to return "1" if the value is 1.00000000.

if tonumber(datafield) = 1.00000000 then '1'
else

local stringvar text:=totext(datafield), 8,"");
local numbervar n:=3;

while text[n] = '0' do

(n:=n+1);
text:= left(text,n);


Any Idea plz?

GJ
IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet Posted: 14 Jul 2010 at 7:29pm
try to help.
 
if int(tonumber(datafield))>0 then totext(int(tonumber(datafield)))
else
   ... yours ...
 
 
hope it work.
 


Edited by Emir_W - 15 Jul 2010 at 11:52am
Emir W
IP IP Logged
Gurojee
Newbie
Newbie


Joined: 23 Feb 2009
Location: India
Online Status: Offline
Posts: 6
Quote Gurojee Replybullet Posted: 18 Jul 2010 at 8:36pm
Hi,

I tried below code
 
if int(tonumber(datafield))>0 then totext(int(tonumber(datafield)))
else

....... mine....


But still same output.....Doesn't return any value.


Confused


IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet Posted: 18 Jul 2010 at 9:58pm
i'm using this formula and it's work for me.
 
note, where {?datastr} is string variable.
 
 
if int(tonumber({?datastr}))>0 then totext(int(tonumber({?datastr})),0)
else
(
  local stringvar text:=totext(tonumber({?datastr}), 8,"");
  local numbervar n:=3;
  while text[n] = '0' do
    (n:=n+1);
  text:= left(text,n);
)
 
i put value:
--> '.00001200', it gives me '0.00001'
--> '1.00000', it gives me '1'
 
 
hope it help.
 
 


Edited by Emir_W - 18 Jul 2010 at 10:01pm
Emir W
IP IP Logged
Gurojee
Newbie
Newbie


Joined: 23 Feb 2009
Location: India
Online Status: Offline
Posts: 6
Quote Gurojee Replybullet Posted: 20 Jul 2010 at 3:24pm
Thanks Emir.... it worked perfectly Big%20smile
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.047 seconds.