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!

Crystal Reports 2008 - WhilePrintingRecords DateDiff for all rows - need average

Status
Not open for further replies.

hmax

Programmer
Jan 22, 2012
60
US
I have the results for each row, based on the following:

whileprintingrecords;
numberVar dur := datediff("s",{Command.CREATION_DATE}, {Command.CLOSED_DTTM}); //get the seconds between 2 dates

Now I need the average of all results for all rows.

Thanks!

hmax
 

Modify your formula slightly:

whileprintingrecords;
numberVar dur := dur + datediff("s",{Command.CREATION_DATE}, {Command.CLOSED_DTTM}); //get the seconds between 2 dates
numbervar counter := counter + 1;

Add an additional formula in the report footer:

whileprintingrecords;
numbervar dur;
numbervar counter;
dur/counter


You'll probably need to add this formula to the report header:

whileprintingrecords;
numbervar dur := 0;
numbervar counter := 0;

 
Hi hmax

Unless I am missing something I can see no reason why you would need to use variables at all. The detail formula could just be:

datediff("s",{Command.CREATION_DATE}, {Command.CLOSED_DTTM}

(or better still, move the calculation to the Command and have the database server do the calculation for you), and then you could just use the normal Average summary to provide that calculation in the footer.
 
Great suggestions, briangriffin and pmax9999. Thank you both!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top