Options

Remove seconds and milliseconds from Duration in Business Central

HensonHenson Member Posts: 5
edited 2020-08-11 in NAV Tips & Tricks
Any ideas guys, thanks

Best Answer

Answers

  • Options
    PhoguePhogue Member Posts: 76
    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;
    
  • Options
    HensonHenson Member Posts: 5
    Answer ✓
    thanks Phogue
  • Options
    krikikriki Member, Moderator Posts: 9,096
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Tips & Tricks' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.