Duration Field x hh:mm format

Answered

Comments

8 comments

  • Rainer Grabowski (FVM)

    Hi Eduardo,

    if I got you right, t3 is something like 10:45 (10 hours 45 minutes). But what is the unit of the "Duration field" (1.456 ???) ? And which kind of field type is it? A calculation field? A real Podio duration field? A niumber field?

    Rainer

    0
    Comment actions Permalink
  • Eduardo Rocha Tavares

    Hi Rainer,

    Yes, you got it right as per the t3 variable.

    When you create a "Duration" field for a Podio app item it lets you enter with hours, minutes and seconds. But when you call that field within a "Calculation" field with the "@" it becomes a float (i.e.: 1.50 instead of 1:30).

    As my t3 variable is using the hh:mm format I cannot subtract the "Duration" field from it. I don't know why Podio handles "Duration" fields that way instead of simply using the hh:mm:ss format as "Date" fields do.

    Have I made myself clear?

    Thanks,

    Eduardo

    0
    Comment actions Permalink
  • Eduardo Rocha Tavares

    Btw, "1.456" is in hours. And I'm referring to the real Podio duration field which is being call from a calculation field.

    0
    Comment actions Permalink
  • Rainer Grabowski (FVM)

    This should work:

    var a = moment(Período Inicial).tz("America/SaoPaulo");
    var b = moment(Período Final).tz("America/SaoPaulo");
    var t1 = moment(a, "hh:mm");
    var t2 = moment(b, "hh:mm");
    var tDur = parseFloat(@duration field);
    var t3 = moment(t2.diff(t1)).subtract(tDur, "hours").format("hh:mm");
    t3

    Rainer

    1
    Comment actions Permalink
  • Eduardo Rocha Tavares

    Perfect! Thanks a lot, Rainer.

    0
    Comment actions Permalink
  • Casper Hesseling

    Hi guys,

    Is there any way just to display a real duration field in another app in hh:mm format by using a calculation field?

    This is what I would like to achieve:

    1. I have an app A with a duration field (Podio duration field in hours and minutes)
    2. I have an app B with a relation to app A. I would like to show the duration field there in the same format as the input format, being "HH: MM". Now 5 hours and 10 minutes displays as 5,16666666667 instead of 5:10.

    It seems so simple, but apparently it is not.

    I hope you guys understand what I am trying to explain here. Thanks a lot for any help in advance. :)

    Casper

    0
    Comment actions Permalink
  • Rainer Grabowski

    Hi Casper,

    here I've explained the way. You've to modify the code a bit to:

    var asMin= @sum of Duration*60;
    var hrs = parseInt(asMin/60); 
    var min = Math.round(asMin % 60);
    hrs + ":" + min

    Hope that helps,
    Rainer

    0
    Comment actions Permalink
  • Casper Hesseling

    Awesome Rainer! You are an absolute Guru! Thanks a lot. :D

    0
    Comment actions Permalink

Please sign in to leave a comment.

Powered by Zendesk