Calculate Number of hours from date field
We have an app that controls our activities. It's connected to our calendars. At the moment we have to manually put in (into a number field) the number of hours/minutes used in an activity in order to track time. Is there a way I can use a calculation to do this? So that the calculations sums the amount of time used in a referenced date field? Ex. I have an activity from 10:00-11:30. All I would have to do is put this in and the calculation would work out it's 1 hour and 30 minutes. (or 1.5 hours).

  • Does anyone have a current update to how this would work with the new time & date fields? I have an app with a tremendous amount of data already entered but we are using a standard date & time field to calculate this. Any advice would be appreciated. 
  • Hi Carlos, this should do it: var usedTime = moment(@endtime).diff(moment(@start time), 'minutes');usedTime > @estimated time ? @estimated time : usedTime Rainer
  • I think my question is related with all of this above! After all the explanation made by Stefan here, I think is relevant ask how to make the real time calculation (field 1 - sums the amount of time) doesn´t exceed the limit set by the estimated time (field 2 - decided by manager)? See below:
  • Thanks for the tip, Stefan! If you don't want your result rounded but want the floating point number, just pass "true" as the last parameter. Like this: var result = d2.diff(d1, 'hours', true); /Ben
  • Hi Jordan, hi Christophe, sorry, I didn't know that non-programmers were allowed to use the advanced calculation field. ;) First of all, you need to change your app. You will have to split your date-field into two separate field, let's call them @Start and @End. The reason behind that required change: advanced calculations can only use the first part of each date-field. I know its not optimal, because of the calendar view... (That all will probably change in the future.) Now that you have done that, you are good to go: var d1 = moment(@Start); var d2 = moment(@End); var result = d2.diff(d1, 'hours'); result; BTW: Christophe, you can vote up questions if you also are looking for the answer. That way they will "rise to the top" and more people will look at them. That's it. Hope that helps. Best, Stefan http://www.diekollaborateure.com/go/podio/help
  • Hi Stefan, I'm sure that is helpful if you know how to use javascript. The advantage of Podio is that non-techies can set it up. This is out of my technical ability by a long way
This question is closed.