1 Reply Latest reply on Jun 20, 2012 5:04 PM by philmodjunk

    Best way to calculate time



      Best way to calculate time


      I am creating a system to create and print rental agreements. I have: Date Out, Date In, Time Out, and Time In. Now this is the script I've created that triggers on object exit for all four of those fields.

      if [IsEmpty ( Invoices::Date Out ) or IsEmpty ( Invoices::Date In ) or IsEmpty ( Invoices::Time Out ) or IsEmpty ( Invoices::Time In )]

      Set Field [Invoices::Actual Days; 0]

      Exit Script []


      Set Field [Invoices::Actual Days; Invoices::Date In - Invoices::Date Out]

      End If


      Now this will give me a number as to how many days they have had the item. Now what I'm trying to do is check the time in and out because I need to make sure that 1 day is being charged as 24 hours (Pickup at 9AM today and return at 9AM tomorrow would be one day, return at noon tomorrow would be two days), but with 1 hour grace period. What would be the best way to do this? Or any way really. Everything I have tried isn't working.

        • 1. Re: Best way to calculate time

          Use time stamp fields instead of separate date and time fields. Each time stamp records the time and date. The difference of two such fields will be the elapsed time in seconds so you can then divide that total to compute total hours.

          And I don't see the need for a script for this, you can define a calculation field such that this computes automatically.