I have an array of dates and i would like to discard any dates that don't have at least one another date in a specific time interval, for example 5 minutes. I need to find a smart way to do it, as loops take forever with a larger dataset.
input data:
2009 07 07 16:01:30
2009 07 07 16:04:06
2009 07 07 16:05:00
2009 07 07 16:12:00
2009 07 07 16:19:43
2009 07 07 16:24:00
results:
2009 07 07 16:01:30
2009 07 07 16:04:06
2009 07 07 16:05:00
2009 07 07 16:19:43
2009 07 07 16:24:00
The value 2009 07 07 16:12:00 was discarded because it was more than 5 minutes away from any other timestamp.
Thanks, Cristi
Secondary issue:
Both Dan and nkjt suggested an implementation that worked, thanks! What if the dates are part of 2 groups: A or B and i want to find if there exist a date from group A that has a corresponding date in group B that is within a number of seconds/minutes apart? if not just remove the date from group A..