Print Page | Close Window

Difference between fields in rows

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=20293
Printed Date: 02 May 2024 at 5:30am


Topic: Difference between fields in rows
Posted By: lolly54
Subject: Difference between fields in rows
Date Posted: 16 Dec 2013 at 10:56pm
Hi All,

I need to get the time difference between two date field in the details section. And then, get the sum of the time difference field.

Sample:
[Details section]

Case# |    Started Date       |    Duration (mins)
01          01/11/2013 09:00              0
02          01/11/2013 10:00              60
03          01/11/2013 12:00              120

[Group Footer]
I would like to show the summary of the duration mins, which will be 180 in this case.

I am using this formula to get the duration
DateDiff("n", Previous({STARTED DATE}), {STARTED DATE})
But I don't think I can use this to calculate the sum of the duration.

My head is hurting Confused... does anyone have any suggestion how to tackle this situation?
I am happy to change the datediff formula as long as I can get the total duration......

Many thanks!!!




Replies:
Posted By: Sastry
Date Posted: 16 Dec 2013 at 11:03pm
Hi

Create the following two formulas to get the total difference :


whileprintingrecords;
Numbervar hr:=hr+{@datediff_Formula}  //your date diff. formula.

Place the above formula in your detail section i.e. where you are calculating time difference.

Whileprintingrecords;
Numbervar hr;


Place this formula in your report footer to get totals.


-------------
Thanks,
Sastry


Posted By: lolly54
Date Posted: 17 Dec 2013 at 1:11am
Thanks Sastry for giving me the idea! Thumbs%20Up
My report is looking more hopeful now.

I have added another formula to initialize the variable and put in the Group Footer. Otherwise, it will carry the previous value over.

[Group Header]
Initialize the variable

[Details]
Variable calculation

[Group Footer]
Displaying the variable result

Thanks again!!!!! (and Merry Christmas!!!)



Print Page | Close Window