Calculate the time difference between consecutive documents