Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: Calculation through multiple rows Post Reply Post New Topic
Author Message
Henry
Newbie
Newbie
Avatar

Joined: 26 Jan 2007
Location: South Africa
Online Status: Offline
Posts: 2
Quote Henry Replybullet Topic: Calculation through multiple rows
    Posted: 26 Jan 2007 at 5:06am
Hi
I would like to calculate the duration between to certain actions in our DB. The times reside in the same table in the columns but in different rows. Example:
"ID"     "Name"     "Task"        "Time"
"1"     "John"     "action begin"     "2007-01-25 10:00"
"2"     "John"     "action end"     "2007-01-25 10:10"
"3"     "John"     "action begin"     "2007-01-26 11:30"
"4"     "John"     "action end"     "2007-01-26 11:45"

I would like to report on the total duration from begin to end. Using the example above I want to indicate that John spent 25 minutes on his tasks.

WHERE DO I START WITH THIS? Any suggestions welcome...
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 26 Jan 2007 at 9:04am
Have two global variables. The first one accumulates the total time taken so far. The second one calculating the difference between the current action. Then do something like this.... (This is psuedo-code, so you will have to tweak it to make it actually work).

Global NumberVar TotalTime
Global DateTime ActionTimeStart

if {Table.Field} = 'action begin' then
       //start the timer
        ActionTimeStart = {Table.DateField};
else
       /calculate total time elapsed and save it
       TotalTime = TotalTime + {Table.DateField} - ActionTimeStart;


Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
Post Reply Post New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum



This page was generated in 0.012 seconds.