Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Calculating Hours and Minutes between dates Post Reply Post New Topic
<< Prev  Page  of 2
Author Message
Tonyak74
Newbie
Newbie
Avatar

Joined: 24 Apr 2013
Online Status: Offline
Posts: 28
Quote Tonyak74 Replybullet Posted: 15 Apr 2015 at 6:21am
Trying to get the time difference between
"Service #1" Service Completed on 04/15/15 01:55:12
and
"Service # 2" Service Completed on 04/15/15 05:25:31
and then the difference between
"Service # 2" Service Completed on 04/15/15 05:25:31
and
"Service # 3" Service Completed on 04/16/15 10:16:11
and then the difference between
"Service # 3 " Service Completed on 04/16/15 10:16:11
and
"Service #4" Service Completed on 04/16/15 14:57:12 
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 15 Apr 2015 at 6:36am
consider using NEXT() or PREVIOUS() functions.
 
if next(table.WO#)=table.WO# then
datediff('n',table.servicecompletedon,next(table.servicecompletedon)) else 0
 
Note the resulting value cannot be summed.
If you want that you would nee to use shared variables.
IP IP Logged
Tonyak74
Newbie
Newbie
Avatar

Joined: 24 Apr 2013
Online Status: Offline
Posts: 28
Quote Tonyak74 Replybullet Posted: 15 Apr 2015 at 7:27am
That was it! Thank you! I really appreciate the help! Seems so simple now :-)

Since I only needed it to count the time between service for WO with more then 1 service.
I created a running total to count the number of services on each WO. I then used your suggestion for Previous() Function. I also divided by 60 to get my hours. Then suppressed the field if Total Service count = 1

if {#WO Service Count} > 1 then
datediff('n',{Service.CompleteOn},previous({Service.CompleteOn})) / 60.00
else 0
IP IP Logged
<< Prev  Page  of 2
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