Forum Discussion

RajHelaiya's avatar
RajHelaiya
Qrew Captain
8 years ago

Find duration between 2 fields with data type (Time of day) ?

How to find duration when start date field is of type (Time of day) and end date field is of type (time of day). I need to find the total duration between start date and end date in terms of days and hours.
  • There is not enough information to be able to do that calculation, since we do not know the day of the start and the stop.

    You need to record the start date and the start time and the end date and the end time.  That can be done either with 4 fields or two fields of type "date/time".
  • ToDays([tod2] - [tod1]) will return a number as fraction of a day. 

    ToHours([tod2] - [tod1]) will return the number of integer hours and a decimal representing the fraction of hours.

  • ... assuming that all data entry is done on the same day and does not cross midnight.

    I was confused because Raj said "in terms of days and hours.
    • RajHelaiya's avatar
      RajHelaiya
      Qrew Captain
      Do you mean the start date and end date should be same day? My use case is something like this:

      Start date can be 1st dec and end date can be 5th dec. Also I need to know the time of start day and end day so I can display a result. For example: "Outage Duratio" was 4 days and 7 hours. Can this be achieved?
    • QuickBaseCoachD's avatar
      QuickBaseCoachD
      Qrew Captain
      Yes no problem, but let me know what you are fields are which are capturing the start date and end date.  i suggest that you make fields for those and btw, a user tip is that if you type a T into a date field it will populate to today.

      So you may want to default the start date to the current day and then users will type a T to set the date when the ticket is closed, as well as the time.  or else you can have a form rule to check a checkbox that will set the  end date to today and the end time to now.
    • RajHelaiya's avatar
      RajHelaiya
      Qrew Captain
      Thank you for your help, I tweaked my field types and was able to find the solution in "Days Format". 
  • I was confused because I answered a question without using JavaScript. Its gonna be a bad day - we have 7 inches of snow coming ...