Display Duration in HH:MM in page field

kmkaotkmkaot Member Posts: 261
Dear Friends,

Will you advice me how to display duration in simple form. like HH::MM format in page

Warm Regards
Kris

Answers

  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    Use a var of Duration type, or assign an expression endtime-starttime as the source expression.
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • kmkaotkmkaot Member Posts: 261
    I got field with Duration data type. Just I need display in my worksheet type page.

    Warm Regards
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    So it should already format the duration properly for you. What's the problem then?
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • kmkaotkmkaot Member Posts: 261
    It is displaying like 30 hours, 40 miniatures, 25 seconds. It should be like 30::40::25
  • Slawek_GuzekSlawek_Guzek Member Posts: 1,690
    If it is only for displaying (no edit) then add a function on your page preparing the duration in the formatting which suits you.

    Unfortunately FORMAT with a format property will not do, the duration values accepts ony 3 standard formatting string, result none of which is close to what you need. At least I am not aware of any other format string which can be applied to the durartion var

    You would have to do someting like this:
    Hours := ROUND(Duration / (60 * 60 * 1000L), 1, '<');
    Minutes := ROUND(Duration / (60 * 1000L), 1, '<') MOD 60;
    Seconds := ROUND(Duration / 1000L, 1, '<') MOD 60;
      
    DurationText := STRSUBSTNO('%1:%2:%3', Hours, Minutes, Seconds);
    
    Or use DotNet vars
    Slawek Guzek
    Dynamics NAV, MS SQL Server, Wherescape RED;
    PRINCE2 Practitioner - License GR657010572SG
    GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03
  • AKAK Member Posts: 226
    edited 2018-01-11
    There is an easier solution by creating a variable of type time, adding the duration to it and format the result:
    TimeVariable := 000000T + durationVariable;
    Message(format(TimeVariable,0,'<Hours>::<Minutes>'));
    

Sign In or Register to comment.