Search code examples
crystal-reports

How can I get the time from a specific location using Crystal Reports?


The company I work for has a parcel-tracking software that we sell to our customers. It uses SQL-database to store the data. And to create reports for the parcels delivery times and other stuff, like exceptions, costs, signatures, we use crystal reports.

One of our customers would like a SLA report, where they want to track the time between a certain location to the time where is has been delivered.

The formula must contain:

  • Package Status, in this case it's LOCSCAN
  • Package Location, it's X-ray
  • And the time that is has been scanned to that location.

I have all the data in the SQL-database, but I cant figure out the formula for this.

A brief description of the workflow:

  • The parcel arrives at the site. They scan it in to the system, thus gets an received date/time, location:Goods and status: RECEIVED.
  • After that they put the parcel trough a x-ray scanner, so it doesnt contain any illegal stuff. Scans the parcel with the new status: LOCSCAN, location:X-ray and a new date/time.
  • After that, they deliver the parcel, to the receiver, and gets status: DELIVERED with a new date/time.
  • All the date/time fields are seperated from eachother, stored in individual columns, dependent on the status of the parcel.

I'm using Crystal Reports, where I'm trying to create the formula.


Solution

  • Use the datediff function:

    datediff('d', {startingdate}, {endingdate})

    First a formula for RECEIVED to LOCSCAN and then LOCSCAN to DELIVERED if I'm understanding correctly.

    The 'd' stands for days, you can replace with 'h' for hours or 's' for seconds. The fields between {} are the ones from database.