Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula results vary 1

Status
Not open for further replies.

simpelli

Programmer
Jul 2, 2003
30
US
Greetings,

I have a field that must display elapsed time in "HH:MM" format. I'm using two calsulated fields for comparison - calculated because of certain criteria.

Here's the formula:
whileprintingrecords;

local numbervar Tmp :=
((datediff("n",cdatetime(shared stringvar UnloadStart),cdateTime(shared stringvar UnloadFinish))));
Local numbervar hrs := Tmp / 60;
Local numbervar Mins := Remainder(tmp,60);

Local StringVar Elapsed :=
Right("00" & cstr(hrs),2) &":" & Right("00" & cstr(mins),2);
Elapsed;

Here's the problem:

On the development computer the string displays correctly
if the times are 10:00 am and 10:03 am the elapsed time is shown as "00:03". On the QA machine, it displays as "05:00".
An elapsed time of
1 min displays as 2hrs
2 min displays as 3hrs
3 min displays as 5hrs
4 min displays as 7hrs

and on and on...

Both machines are running Win2000, Crystal9 developer with SP1, both environments are setu identically (number formats, date/time formats, etc), going against Informix db

Any ideas??
 
I have a FAQ in this forum: faq767-3543

Try:

whileprintingrecords;
local numbervar dur :=
((datediff("s",cdatetime(shared stringvar UnloadStart),cdateTime(shared stringvar UnloadFinish))));
numberVar hrs;
numberVar min;
stringVar hhmmss;
hrs := Truncate(Truncate(dur/60)/60);
min := Remainder(Truncate(dur/60),60);
hhmmss := totext(hrs, "0") + ":" + totext(min, "00") ;
hhmmss

-k
 
Thanks...

That did the trick! Not a lot different in the code, but probably more precision? I logged an incident with CR Support a few days ago & they weren't close..

Why would this issue happen in the first place?
 
Could be the form of the concatenation and settings on the box, note that I used + not &.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top