Dear Mosesc,
Just a note for you on the field you are using. You are reporting against a MagicTSD database. Using the Status ID field may give you erroneous results.
The Status ID field supports User Defined Statuses which ultimately resolve to a State: of Open or Closed. If your organiation has or will in the future have additional statuses, your formula would be incorrect as you assume that any status that is not Closed is Open... this may or may not be the case. Statuses could be Resolved, Research, On Hold, etc.
The best course of action would be to use the Incident.State: field in your calculation.
Here is the formula I use, which gives the same results as Jim's except I like 2 digits as in 00:00:00:00 as the format:
//Convert Total Seconds to D H M S
WhilePrintingRecords;
Datetimevar d1 := {Incident.Open Date & Time};
Datetimevar d2 := If {Incident.State:} = 'C' then {Incident.Close Date & Time} else CurrentDateTime;
NumberVar TotalSec := datediff("s", d1, d2);
NumberVar Days := Truncate (TotalSec / 86400);
NumberVar Hours := Truncate (Remainder ( TotalSec,86400) / 3600);
NumberVar Minutes := Truncate (Remainder ( TotalSec,3600) / 60);
NumberVar Seconds := Remainder ( TotalSec , 60);
Totext ( Days, '00', 0,'') + ':'+
Totext ( Hours, '00', 0,'') + ':'+
Totext ( Minutes,'00', 0,'') + ':'+
Totext ( Seconds,'00', 0,'')
Best regards,
ro
Rosemary Lieberman
rosemary@microflo.com,
Microflo provides expert consulting on MagicTSD and Crystal Reports.