Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Difference between timestamps greater than 2 minutes

Hello,

I have a database that records a date and timestamp against every transaction and essentially I want to flag up and sum (over a day, week etc) the amount of time between transactions when the difference between them is more than 2 minutes. See below example.

TransactionTimestampDifference
12012-06-08 12:09:12
22012-06-08 12:10:1200:01:00
32012-06-08 12:14:1200:04:00
42012-06-08 12:15:1200:01:00
52012-06-08 12.26:1200:11:00
62012-06-08 12:45:1200:19:00
72012-06-08 12:46:1200:01:00

In this example the total difference between timestamps is 37 minutes, however I don't care about when the difference is less than 2 minutes so don't require 3 of the transactions so the difference I want to see is 34 minutes. I'm thinking that using peek and an if statement in the script will work but any other suggestions?

Thanks,

Ralph

3 Replies
Not applicable
Author

Hi Ralph,

that table above is the input?

And the output should be

TransactionTimestampDifference
12012-06-08 12:09:12


32012-06-08 12:14:1200:04:00


52012-06-08 12.26:1200:11:00
62012-06-08 12:45:1200:19:00


?

In the script I would use

LOAD Transaction, Timestamp, Difference

from ...

where Difference > Timestamp#('00:02:00', 'hh:mm:ss');

Ciao

Klaus

Not applicable
Author

Hi Klaus,

This would work although I need to include all other transactions as well so I would need to essentially add a flag when the difference is greater than 2 minutes as well as summing the differences.

Thanks,


Ralph

Not applicable
Author

Ok Ralpf,

for the flag take

LOAD

     IF(Difference > Timestamp#('00:02:00', 'hh:mm:ss'), 1, 0) as relevant_difference,

....

and where do you want to store the sum

or do you need the sum in some chart?

Ciao

Klaus