• well i found a bug with the code posted and that is it doesn't include records that stay longer than a day...

    so back to square one.