Trip Creation of Device before deleting old data from traccar

I need to calculate trip for all my devices before deleting data for previous months. I only want data for last 2 months in my application. How can i calculate trips for data before i delete it