| Author |
Message |
rhart36
Newbie
Joined: 10 Nov 2015
Location: United States
Online Status: Offline
Posts: 4
|

Topic: Help calculating time difference with records Posted: 11 Nov 2015 at 7:22am |
|
I need help calculating the time difference between two records based on a 3rd field value. For instance, I need to calculate the time difference in the below table when the status equals WAPPR and COMP. Please note these are different rows within a table. I will also need calculate the time difference between other Status changes.
Table:
WONUM STATUS CHANGEDATE
TKT9904 COMP 10/16/2014 7:59
TKT9904 REVIEW 10/16/2014 7:59
TKT9904 APPR 10/14/2014 9:31
TKT9904 WAPPR 10/13/2014 11:19
TKT9904 INPRG 10/15/2014 8:01
TKT9904 AUTH 10/13/2014 12:16
TKT9904 SCHED 10/13/2014 12:16
TKT9904 AUTH 10/13/2014 12:17
TKT9904 ASSESS 10/13/2014 11:39
Any Assistance would be greatly appreciated!!
|
IP Logged |
|
|
|
rhart36
Newbie
Joined: 10 Nov 2015
Location: United States
Online Status: Offline
Posts: 4
|

Posted: 16 Nov 2015 at 2:25am |
|
any help would be greatly appreciated
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 16 Nov 2015 at 3:04am |
|
do you need to do additional work with the various results or just display them in the group header or footer?
Can you write or use a stored procedure to get this data?
|
IP Logged |
|
rhart36
Newbie
Joined: 10 Nov 2015
Location: United States
Online Status: Offline
Posts: 4
|

Posted: 16 Nov 2015 at 3:12am |
|
Basically I'm trying to calculate total time tickets were opened and then the time difference as the ticket moves through each of the status'.
I haven't used SQL stored procedures in Crystal.
BTW - Thanks for you quick response.
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 16 Nov 2015 at 3:26am |
|
Some options:
1. if you can sort them in a row sequence that allows you to do calculations off next() or previous() that would be one way.
e.g. datediff('n',table.changedate,next(table.changedate))
2.You can use several formula to get the status value at a group level per status type then do group calculations from those. This assumes you are grouping on WONUM
e.g.
@compdate as: if status = 'COMP' then changedate ELSE '1/1/1900'
group result: max(@compdate,wonum)
repeat for the different types
you can now use these in another formula
datediff('n',max(@compdate,wonum),max(@wapprdate,wonum))
3. use a command or stored proc to get the data in a more friendly column format
-1 option is to use pivot on the various dates
-another option is to join the table to itself and have conditions on the join.
if you need to do additional report summaries on the results the stored proc or command are your best options. You cannot really do more calculations on next/previous results or the group results.
|
IP Logged |
|
rhart36
Newbie
Joined: 10 Nov 2015
Location: United States
Online Status: Offline
Posts: 4
|

Posted: 16 Nov 2015 at 3:34am |
|
thanks, I'll give this a try. I'm thinking the stored procedure is the way to go, just need to figure out the syntax.
|
IP Logged |
|
|
|