Options

Time Duration Format

jpjesusjpjesus Member Posts: 45
Hi,

I am trying to create a dialog box where I can show an estimation on how long it will take to performe a task. In this case, I know it might take a long time so I want to give the user an idea on how long it will take.

The real problem is when I want to represent the duration in this notation: hh:mm:ss.

I know that the formula time1 minus time2 (dur := time1 - time2) results in a duration value.
I can show it with its basic notation. For example: '1 minute 10 seconds 136 milliseconds'

What I would like to do is show it as: 00:01:10 (hh:mm:ss).

I've tried to use the format function but it doesn't work:
FORMAT(durRemaining,0,'<Hours24,2>:<Minutes,2>:<Seconds,2>')
I get the error: Internal Error 47-1. It has something to do with the fin.stx file.

Any help is welcome.

Cheers,
Joao

Comments

  • Options
    Luc_VanDyckLuc_VanDyck Member, Moderator, Administrator Posts: 3,633
    Try this example:
    OBJECT Form 90000 test duration
    {
      OBJECT-PROPERTIES
      {
        Date=07/12/06;
        Time=12:32:46;
        Modified=Yes;
        Version List=;
      }
      PROPERTIES
      {
        Width=8000;
        Height=8000;
        OnOpenForm=BEGIN
                     decTime1 := fctTime2Decimal(TIME);
                   END;
    
        OnCloseForm=BEGIN
                      decTime2 := fctTime2Decimal(TIME);
                      decDuration := decTime2 - decTime1;
                      MESSAGE('Duration: %1',fctDecimal2Time(decDuration));
                    END;
    
      }
      CONTROLS
      {
      }
      CODE
      {
        VAR
          decDuration@1000000002 : Decimal;
          decTime1@1000000003 : Decimal;
          decTime2@1000000004 : Decimal;
    
        PROCEDURE fctTime2Decimal@1000000000(T@1000000000 : Time) : Decimal;
        VAR
          d@1000000001 : Decimal;
        BEGIN
          //fctTime2Decimal
    
          IF T = 0T THEN
            EXIT(0.0);
          d := T- 000001T + 1000.0;
          EXIT(d / 3600000);
        END;
    
        PROCEDURE fctDecimal2Time@1000000002(D@1000000000 : Decimal) : Time;
        BEGIN
          //fctDecimal2Time
    
          IF D = 0.0 THEN
            EXIT(0T)
          ELSE
            EXIT(000001T + (ROUND((D * 3600000 - 1000),1)));
        END;
    
        BEGIN
        END.
      }
    }
    
    

    Run the form through the Object Designer, then close the form. The duration will then be displayed.
    No support using PM or e-mail - Please use this forum. BC TechDays 2024: 13 & 14 June 2024, Antwerp (Belgium)
  • Options
    jpjesusjpjesus Member Posts: 45
    Thanks very much for your help.

    And as usual, most solutions are the simple ones.

    All it takes to show the duration in 'hh:mm:ss' notation is to create a time variable (timeDuration) and then do the following:

    timeDuration := 000000T + durDuration;

    It's that simple.

    Cheers,
    Joao
Sign In or Register to comment.