Possible to prepend a numeric value in RAPID?

  • Hello,


    I am working on a function that converts seconds to time:




    The problem I'm having is when you input an amount of seconds that returns minutes that are less than 10, a zero is missing. For example 5:05 PM (18300 seconds) reads as 5:5 instead of 5:05. Is there a RAPID command that allows me to prepend a zero? I've looked through the Technical Reference Manual and can't seem to find anything like this. Thanks for your help.

  • I have found the solution now, the trick is to add another IF statement at the bottom of the function. Instead of:



    RETURN NumToStr(hours,0) + ":" + NumToStr(minutes,0);



    You need:



    IF minutes < 10 THEN



    RETURN NumToStr(hours,0) + ":" + "0" + NumToStr(minutes,0);



    ELSE



    RETURN NumToStr(hours,0) + ":" + NumToStr(minutes,0);



    ENDIF

Advertising from our partners