Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Calculate the time difference between 2 different Post Reply Post New Topic
Author Message
DrewEC
Newbie
Newbie


Joined: 02 Sep 2020
Online Status: Offline
Posts: 7
Quote DrewEC Replybullet Topic: Calculate the time difference between 2 different
    Posted: 15 Apr 2021 at 12:57pm
Hello there, thank you for looking at my question.

An example of the data that I have is as follows:



The logic for my formula is as follows:

If the unitcode equals GMTST1 and the descript equals "Dispatched", then subtract the any other unitcode's "Arrived" timestamp, from the GMST1 "Dispatched" timestamp.

Basically, GMST1 is the baseline for when a unit is technically dispatched (not the Dispatched time next to GMAT18 or GMAT1 for example). I'm trying to find the time it takes from GMST1 dispatch, to each individual unit's arrival time.

So if GMAT1 and GMAT 18 were dispatched for the same event, both of their individual response times should be represented by subtracting GMTST1's dispatched time, from their own arrival time.




I tried using a datediff formula, but kept getting errors, or incorrect numbers. Thank you so much for your time and assistance!


(As a side note, these are all grouped by event numbers, and each group is separated by a line)
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 16 Apr 2021 at 5:13am
I am not sure that I understand all of the logic. With that said, and from what I see on the report sample, the data is on different lines, in different rows. If that is the case there are a couple of ways to handle the formula.

If the 2 values that you are after are always grouped and next to each other on the report, life is simpler as you can you NEXT or PREVIOUS depending on where your formula to display.

For example, if you display the difference on the Arrived line, the formula would look something like:
DATEDIFF("minute", {TimeStamp}, PREVIOUS({TimeStamp}))

I might have gotten the order wrong, and the syntax with minute, it differs slightly from SQL, and I am sure that you get the idea.

Some caveats to remember, the formula is not smart, and you need to put in the logic to only work with, in this case, the row is an 'Arrived'.

If the values are not next to each other, it is more work as you will need to devise a method to 1) remember what the previous value was, 2) when it the correct time to display the value, and 3) how to match up the values.

Hope that this helpful and not more confusing.
IP IP Logged
DrewEC
Newbie
Newbie


Joined: 02 Sep 2020
Online Status: Offline
Posts: 7
Quote DrewEC Replybullet Posted: 19 Apr 2021 at 3:35am
Thank you for taking the time to review and reply to my question.

You're on the right track with the formula provided, but unfortunately the values are not always grouped next to each other so next/previous doesn't work.

I think finding out how to match the values is going to be the most difficult part in this, as it's not really possible. At the end of the day, it's really an issue with our processes and how data is stored in our database.

Thank you again!
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.016 seconds.