Time between dates, subtracting dates, times

We had a situation where we were tracking run time on a machine, but the owner wanted to know what the EU (Equipment Utilization as a %) for that equipment was. We used two pop-up calendars - one for start date/time, and one for end/date time, used in the query. We already had the total run time for that period, but that had to be subtracted from the total available time for that period. Thus the difference (in minutes) between the start date/time and end date/time had to be determined.
The way to find the difference in minutes between the two dates, which seemed to work best, is to:

  1. create three dynamic properties: Start_Time_Long, End_Time_Long, Time_Diff. (all are integers)
  2. on the Start and End time properties, create an expression that type casts your dates toLong.
  3. this will create long integers out of the dates and times.
  4. in the Time_Diff property created and expression that says: (End_Time_Long - Start_Time_Long) / 59983.65.
  5. the rsulting integer in the Time_Diff property will be the amount of time in Minutes between the Start date/time and the End date/time.
  6. If you need seconds, or hours, etc. you can modify the divisor to get whatever scale is appropriate fo your application.

Hope this helps somebody.

I know I’m a little late with this, but it would be much easier to do this using the dateDiff expression.

Just bind your Time_Diff integer property to an expression like:

dateDiff({Root Container.StartDate.Date}, {Root Container.EndDate.Date}, "min")