Remove milliseconds from duration variable

CobaltSSCobaltSS Member Posts: 137
Hi,

I would like to remove the milliseconds portion of a duration variable on a report. Any ideas greatly appreciated.

cheers,

Answers

  • CobaltSSCobaltSS Member Posts: 137
    Thanks for the quick reply, Harry,

    However, that solution doesn't address the problem (although I think I'll use it elsewhere). For this application, I just need to show the duration as x days, y hours, z minutes. The time format doesn't really do this for me. All I need here is to strip the milliseconds (and seconds, if possible) from the report. Is there another way?

    cheers,
  • SavatageSavatage Member Posts: 7,142
    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;

    I don't work at all with time but when I read this I figured it was just about adding or dividing it out :-k

    I assume you've tried the FORMAT command
    example
    MESSAGE('%1',FORMAT(YourTime,4,1);

    See help for more info
    FORMAT(YourTime,'<Hours12,2>:<Minutes,2>:<Seconds 0 dec.> <AM/PM>');
  • CobaltSSCobaltSS Member Posts: 137
    When I add the 0T to the Duration variable it does convert it to a time. But the Duration variable is not a TIME data type, it's a DURATION data type. It's created (in my case, anyway) by subtracting one datetime data type from another datetime datatype. When it prints on the report it prints 9 days, 9 hour, 9 minutes, 9 seconds, 999 milliseconds. For my purposes, I only need to see down to the minutes. (The time result is 9:09:09.999 (I think) when I add the Duration datatype to 0T).

    cheers,
  • SavatageSavatage Member Posts: 7,142
    try format???
    See help for more info
    FORMAT(YourTime,'<Hours12,2>:<Minutes,2>:<Seconds 0 dec.> <AM/PM>');

    delete the sconds part if you don't want it.
  • pdjpdj Member Posts: 643
    MyDuration := ROUND(MyDuration,1000); // The simpler the better 8)
    Regards
    Peter
  • CobaltSSCobaltSS Member Posts: 137
    Nicely done.

    Thanks very much.

    cheers,
Sign In or Register to comment.