Calculate Number of hours from date field

Comments

9 comments

  • Stefan Ukena

    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

    4
    Comment actions Permalink
  • Dan Stroehlein

    How do you add X hours to a date in a calculation?

    1
    Comment actions Permalink
  • Stefan Ukena

    Hi Jordan,

    the calculation fields includes this handy little library that let's you do all sorts of things with dates:

    http://momentjs.com/docs/

    Best,
    Stefan

    http://www.diekollaborateure.com/go/podio/help

    0
    Comment actions Permalink
  • Jordan Fleming

    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

    0
    Comment actions Permalink
  • I am also interested in this functionality.

    0
    Comment actions Permalink
  • Benjamin Christensen

    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

    0
    Comment actions Permalink
  • Carlos Noetzold

    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:

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Carlos,

    this should do it:

    var usedTime = moment(@endtime).diff(moment(@start time), 'minutes');
    usedTime > @estimated time ? @estimated time : usedTime

    Rainer

    0
    Comment actions Permalink
  • Jeremy John Wells

    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. 

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk