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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SUM OF TIMES

Status
Not open for further replies.

Phillipg

Technical User
May 3, 2002
53
US
I can’t figure out how to get the sum of time fields that I need. I have two details sections grouped together by {Incedent.unitid}. The fields that hold the times are Date/Time fields.
In detail a, the field {incedent.timealerted} is shown and also the field {@tohoursmin}.

The formula for {tohoursmin} is as follows:
WhilePrintingRecords;
numbervar thehours;
numbervar themins;
numbervar thesecs;

thesecs:=Remainder({@diff},60);
themins:=Remainder(truncate({@diff}/60),60);
thehours:=Remainder(truncate(truncate({@diff}/60)/60),60);

totext(thehours,"##")+":"+totext(themins,"00");

In the detail b section, the fields are {incedent.date} and {incedent.timeinservice}.

Formula’s,
{@diff} is
DateDiff ('s',{@previnservice} ,{INCIDENT.TIMEALERTED} )
{@previousinservice} is
previous({INCIDENT.TIMEINSERVICE})

how can I total the field {@tohoursmin) and place in the group footer?
thanks, Phillipg




 
I assume that you want this totaled per group:

Place this in the group header:

//resets the sum
Whileprintingrecords;
numbervar groupsecs := 0;

Modify this in your detail:

// Added groupsecs to contain total secs
WhilePrintingRecords;
numbervar thehours;
numbervar themins;
numbervar thesecs;
numbervar groupsecs;

groupsecs := groupsecs + DateDiff ('s',{@previnservice} ,{INCIDENT.TIMEALERTED} );

thesecs:=Remainder({@diff},60);
themins:=Remainder(truncate({@diff}/60),60);
thehours:=Remainder(truncate(truncate({@diff}/60)/60),60);

Place this in your group footer:

// Display groupsecs
Whileprintingrecords;
numbervar groupsecs

This will sum the secs and reset them at each group, you can format it as you do in the detail section if needed.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top