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:0011: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).

Hi Jordan,
the calculation fields includes this handy little library that let's you do all sorts of things with dates:
Best,
Stefan 
Hi Jordan, hi Christophe,
sorry, I didn't know that nonprogrammers were allowed to use the advanced calculation field. ;)
First of all, you need to change your app. You will have to split your datefield 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 datefield. 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 
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:
Please sign in to leave a comment.
Comments
9 comments