How to display in HH:MM:SS when only seconds are available ?

I have a timer with elapsed time available in seconds.

How can i display the time available in seconds, In HH:MM:SS format ?

  • You could use an expression in an action block to parse out the values you want and piece them into a string.

    HOURS := TRUNC('^/TOTAL_SECS.CV'/3600);
    MINUTES := TRUNC(('^/TOTAL_SECS.CV' - (HOURS * 3600))/60);
    SECS := TRUNC('^/TOTAL_SECS.CV' - (HOURS * 3600) - (MINUTES * 60));

    IF HOURS < 10 THEN
    '^/DISPLAY_TIME_HR.CV' := "0" + HOURS;
    ELSE
    '^/DISPLAY_TIME_HR.CV' := HOURS;
    ENDIF;
    IF MINUTES < 10 THEN
    '^/DISPLAY_TIME_HR.CV' := '^/DISPLAY_TIME_HR.CV' + ":0" + MINUTES;
    ELSE
    '^/DISPLAY_TIME_HR.CV' := '^/DISPLAY_TIME_HR.CV' + ":" + MINUTES;
    ENDIF;
    IF SECS < 10 THEN
    '^/DISPLAY_TIME_HR.CV' := '^/DISPLAY_TIME_HR.CV' + ":0" + SECS;
    ELSE
    '^/DISPLAY_TIME_HR.CV' := '^/DISPLAY_TIME_HR.CV' + ":" + SECS;
    ENDIF;
  • In reply to Lance Dusing:

    Rohan,

    This topic has been around for a while. It might be possible to also use VB in Operate to display in desired format without having to take up controller exec time.

    I really like DeltaV, but I'm amazed this is still an issue. I used HMIs for PLCs and old DCS platforms 20 years ago that allowed the user to simply specify an HH:MM:SS format (even option for days) for an integer value.
  • Can you try this:

    FORMATTED_TIMER.CV := TIME_TO_STR("%T", TIMER_IN_SECONDS.CV)

    where
    FORMATTED_TIMER is an input "STRING" parameter and TIMER_IN_SECONDS is an input "32-bit unsigned integer" parameter
  • In reply to GeloCortez:

    That is a good option. Works well if the timer value is less than one day (86400 seconds), otherwise additional logic is needed to calculate and include the number of days.

    I would still love to see a format option in Operate so that logic would not be required for each instance.