Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>There is no straightforward answer as this depends on what you consider to be a match. There are simple as well as complicated approaches and anywhere in between. You'll need to come up with the algorithm for that. An easy approach would be to shave off the seconds and just match down to the minute however that may be too long. You could write a method normalizes timestamps down to 5 or 10 seconds and group on that as suggested already.</p> <p>If you want to group any two messages that are within x seconds together then this approach will only mostly work. There will always be those values that are within the range but fall on either side of the cutoff. If you are OK with this and value simplicity, then the above answer will work.</p> <p>If that doesn't work and you want to group across the artificial cutoff then you'll need another approach. A simple approach in this case could be that you use LINQ to group by everything but the timestamp. This will do a preliminary grouping of your data. Then you can iterate through each group and compare each time value to each other time value in the same group and determine if it is within your range. Then manually grab those values that fall within the specified range and group them together.</p> <p>This has an additional edge case that you'll need to make a decision on. If you decide that you will group within 1 second and you have three entries whose seconds are (simplified) 1, 2, and 3. 1 and 2 are within a second and 2 and 3 are also within a second but 1 and 3 aren't. Would you group these based on 2 being within one second of the others, or would you group 1 and 2, making 2 ineligible to be grouped with 3 and 3 would be by itself.</p> <p>You'll ultimately wind up with a solution who's bucket's can grow based on chaining values together, or a different artificial cutoff based on first group created rather than hard time cutoffs. The hard time is far more simple so unless you are going to have growing buckets, I'd recommend just going with a normalized timestamp and grouping on that.</p> <p>You need to define what you mean by almost and plan accordingly.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload