Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Converting Seconds to Minutes Post Reply Post New Topic
Author Message
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Topic: Converting Seconds to Minutes
    Posted: 03 Jun 2010 at 5:30am
Trying to get a more precise formula for this. Currently am using this:
 
whileprintingrecords;
NumberVar Days    := Truncate (global numbervar nIReady / 86400);
NumberVar Hours   := Truncate (Remainder (global numbervar nIReady , 86400) / 3600);
NumberVar Minutes := Truncate (Remainder (global numbervar nIReady , 3600) / 60);
NumberVar Seconds := Remainder (global numbervar nIReady , 60) ;
if nIReady=0
    then 0
        else
(Days*1440)+(Hours*60) + Minutes + (Seconds/60)
 
Is there a better way of doing this? Seems like I'm getting some numbers that are a bit off with the current formula.
 
 
Background
I have a report that logs a time everytime an agent changes state throughout the day. The first log time begins the state and the next log time ends the current state and begins the next state. To get the time I take the first log time and subtract it from the next log time to get the difference in seconds. I need to convert the seconds to minutes.
 
Thanks.
|< /\ '][' ( )
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 07 Jun 2010 at 3:55am
global numbervar nIReady;
local numbervar intLeft := nIReady
NumberVar Days    := Truncate ( intLeft / 86400);
 intLeft :=  intLeft - Days * 86400;
NumberVar Hours   := Truncate ( intLeft / 3600);
  intLeft :=  intLeft  - Hours *3600;
NumberVar Minutes := Truncate ( intLeft  / 60);
  intLeft :=  intLeft - Minutes * 60
NumberVar Seconds :=  intLeft ;
if nIReady=0
    then 0
        else
(Days*1440)+(Hours*60) + Minutes + (Seconds/60)
 
 
It's not clean, but I think that Remainder is not working as one would think...at least in my head...I have never used the funtion so I may be mistaken.
 
HTH
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 15 Jun 2010 at 2:29am
Thanks for the reply.
 
The formula you provided is giving me a 0 value. Any idea what could be wrong? I had to add a semicolon after the intLeft := nIReady and Minutes * 60 as it was throwing and error. So I've done that. But I'm still getting 0.
|< /\ '][' ( )
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 15 Jun 2010 at 3:05am

I would start to figure out what is happening by commenting out parts of the formula or build smaller formulas that show each part of the formula so that you can see what it is doing.

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.000 seconds.