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

Difference in Time

Status
Not open for further replies.

dannyb29

Technical User
Nov 10, 2010
90
GB
Hi All,

Is there a way of calculating the difference in time between each transaction and displaying it in the detail of the report and then working out an aveage and display it in the group header.

Dannyb
 
dannyb29,

Please look into the [blue]DateDiff[/blue]() Function in Crystal Reports Help, it will provide you with the syntax on how to acheive what you seek.

If you have anything more specific, please post.

Hope this helps, cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
The problem is that you are comparing a sequence of records, and would need to use a variable to average the results, which would be available in the group footer. To have the results in the group header, you could insert a subreport that does replicates the main report and is linked on the group field and placed in the group header. Suppress all sections except the group footer where the average is showing. The formula in the detail of the sub would look like this (assuming dates are sorted in ascending order):

whileprintingrecords;
numbervar secs;
numbervar cnt;
if not onfirstrecord then(
secs := secs + datediff("s",previous({table.datetime}),{table.datetime});
cnt := cnt + 1
);

//sub group footer formula:
whileprintingrecords;
numbervar secs;
numbervar cnt;
secs/cnt

This would exclude the first record of each group from the count and datediff, since there is no previous transaction.

-LB
 
MCuthill - The datediff() only calculates the dfferents in dates rather than time.

Lbass - I am not familiar with subreports, but I think I have followed your instructions correctly.
I have got to point where I add the code to the:
section expert-> details ->supress(no drill down)-> x2
but it is throwing up an error. "a bolean is required here"

dannyb
 
No, that is not what I meant. Just suppress the subreport detail section and group header directly. The formulas should be created in the subreport in the field explorer->formula->new. The first formula should be placed in the suppressed detail section of the sub, and the second formula belongs in the group footer of the sub.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top