Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: time stamp question Post Reply Post New Topic
Author Message
skyliner34
Newbie
Newbie


Joined: 20 Oct 2011
Online Status: Offline
Posts: 18
Quote skyliner34 Replybullet Topic: time stamp question
     Posted: 03 Feb 2012 at 4:39am
What I am looking at doing is displaying the length a call spent as open in one of my reports. But need the time displayed to be of a more meaningful format.
 
As an example, here is the create date of a call 
19/12/2011  17:20:41
 
and here is the resolved date
 
03/01/2012  12:07:14
 
 The formula I have been using is
 
 {HPD_HelpDesk.Status_History_Resolved_TIME}-{HPD_HelpDesk.Create_Time}
 
this produces an open time of
 
14.78
So I can presume the call has been open for 14 days (can't work out the 78). So how can I show the time as 14 days x hours x minutes?
 
IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 03 Feb 2012 at 5:11am
Start by creating a formula to obtain the difference in seconds:

datediff('s', {table.resolvedtime}, {table.createtime})

Then create the following formula:

whileprintingrecords;

NumberVar Days    := Truncate ({@TotalSeconds} / 86400);
NumberVar Hours   := Truncate (Remainder ({@TotalSeconds} , 86400) / 3600);
NumberVar Minutes := Truncate (Remainder ({@TotalSeconds} , 3600) / 60);
NumberVar Seconds := Remainder ({@TotalSeconds} , 60) ;

if {@TotalSeconds}=0
    then '0'
        else
totext(Days,0) & ':' & totext(Hours,0) & ':' & totext(Minutes,0) & ':' & totext(Seconds,0)


You could play around with this so it won't show the preceeding zeros for Days, Hours and/or Minutes if they are blank and to format it how you want it. But this should get you started.


Edited by FrnhtGLI - 03 Feb 2012 at 5:12am
|< /\ '][' ( )
IP IP Logged
skyliner34
Newbie
Newbie


Joined: 20 Oct 2011
Online Status: Offline
Posts: 18
Quote skyliner34 Replybullet Posted: 05 Feb 2012 at 11:57pm
That works superb. Many thanks for your help :)
IP IP Logged
gravytrain
Newbie
Newbie
Avatar

Joined: 10 May 2012
Location: Canada
Online Status: Offline
Posts: 5
Quote gravytrain Replybullet Posted: 10 May 2012 at 7:51am
I was curious if you were using any type of formula for Work Days (Monday to Friday / 8am to 5pm) excluding weekends and holidays?
I have a query I have been exporting to Excel and using the Networkdays function, but would love to figure it out in Crystal Reports?
JG
IP IP Logged
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