Remove seconds and milliseconds from Duration in Business Central

HensonHenson Member Posts: 3
Any ideas guys, thanks

Best Answer

Answers

  • PhoguePhogue Member Posts: 71
    Duration is stored as a 64-bit integer, representing the milliseconds in the duration.

    If you wish to remove 1 second, just subtract 1000 from the Duration variable.
    local procedure TestDateTime()
        var
            DateTime1: DateTime;
            DateTime2: DateTime;
            Duration1: Duration;
        begin
            DateTime1 := CreateDateTime(20090101D, 080000T); // January 1, 2009 at 08:00:00 AM  
            DateTime2 := CreateDateTime(20090505D, 133001T); // May 5, 2009 at 1:30:01 PM  
            Duration1 := DateTime2 - DateTime1;
            Message(format(Duration1)); //124 days 4 hours 30 minutes 1 second
            Duration1 -= 1000;
            Message(format(Duration1)); //124 days 4 hours 30 minutes
        end;
    
  • HensonHenson Member Posts: 3
    Accepted Answer
    thanks Phogue
Sign In or Register to comment.