Print Page | Close Window

Problem with visualisation of formatted number

Printed From: Crystal Reports Book
Category: Crystal Reports for Visual Studio 2005 and Newer
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=6981
Printed Date: 01 May 2024 at 4:03am


Topic: Problem with visualisation of formatted number
Posted By: Bjorn-V
Subject: Problem with visualisation of formatted number
Date Posted: 07 Jul 2009 at 6:23am
Hey,

my report is based on a database.
In the database their is an integer field with the time in seconds.
The people who uses the report wants to view this number in
hours:minutes:seconds. Changing the database is a no go, because the program uses those seconds to calculate several things.

I formated the number with a calculation in the formula editor but now it always shows decimals.
My question is how to remove those decimals.

For example:
Database : 554
after calculating it becomes 9 min and 14 seconds but the report displays it like this: 0,00:9,00:14,00

My code to do this is:
Local numberVar i := ToNumber({tblGesprek.duratiecommunicatie});
Local stringvar outputString := "";
Local numberVar uren := 0;
Local numberVar minuten := 0;
Local numberVar seconden := 0;

while i >= 3600 do
(
uren := uren + 1;
i := i - 3600;
);

while i >= 60 do
(
minuten := minuten + 1;
i := i - 60;
);
seconden := i;

uren := Truncate(uren);
minuten := Truncate(minuten);
seconden := Truncate(seconden);

outputString := ToText(Truncate(uren)) + ":" + ToText(Truncate(minuten)) + ":" + ToText(Truncate(seconden));


the code to calculate the time is correct but i want the decimals to disappear!
How is this possible??

Thanks in advance and sorry about the english



Replies:
Posted By: lockwelle
Date Posted: 21 Jul 2009 at 6:38am
outputString := ToText(Truncate(uren),0,"") + ":" + ToText(Truncate(minuten),0,"") + ":" + ToText(Truncate(seconden),0,"");
 
your totext is not telling Crystal to give 0 decimal places and to use "" for the thousand separator.
 
Changes given should help.




Print Page | Close Window