web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Duration datatype in reports

(0) ShareShare
ReportReport
Posted on by 700

Hi All, 

I have to display a field in a report whose datatype is Duration i.e. it displays the data as '8 hours 8 minutes 8 seconds'. But I have to display the data in hh:mm:ss format. Can I do this ? If yes, please suggest the way. I tried using Format function but it didn' work.

Thanks !

  • Suggested answer
    ArturV Profile Picture
    225 on at

    You can easily convert the duration variable into the time variable and then call the format function. Here is a simple code snippet on how to show the time in your format.

    CurrDuration := 40000000;

    MESSAGE(FORMAT(000000T + CurrDuration));

  • Dynamics 365 Business Central Profile Picture
    700 on at

    I have handled Hours, Minutes and Seconds but Day is not getting displayed.

    I used :

    DurTime := 000000T + "Job Task"."Audio Minutes2";

    &

    column(Audio_Minutes2; FORMAT(DurTime, 0, '<Hours24>:<Minutes,2>:<Seconds,2>')) { }

    DurTime is Time variable. Please suggest.

  • Suggested answer
    ArturV Profile Picture
    225 on at

    Calculate the days separately and then add before the time:

    CurrDuration := 99999999;

    CurrTime := 000000T + CurrDuration;

    Days := CurrDuration DIV 86400000;

    IF Days <> 0 THEN

     ReportValue += FORMAT(Days,0,'<Integer,2>') + ':';

    ReportValue += FORMAT(CurrTime,0,'<Hours24>:<Minutes,2>:<Seconds,2>');

    MESSAGE(ReportValue);

  • Dynamics 365 Business Central Profile Picture
    700 on at

    Is it possible to add days in the hours ? For example, in case of 2 days, 48 hrs should be added in the 'Hours' field.

  • Suggested answer
    ArturV Profile Picture
    225 on at

    Calculate days, hours, minutes and seconds individually as integers by dividing duration on 1000, 60000 and so on, then do

    FORMAT(%1:%2:%3:%4,Days * 24 + Hours,Minutes,Seconds);

  • Dynamics 365 Business Central Profile Picture
    700 on at

    It is displaying 0 value in the column.

    Below is my code :

    column(Audio_Minutes2; FORMAT(Days_ms * 24 + Hours_ms, Minutes_ms, Seconds_ms)) { }

    trigger OnAfterGetRecord()

               var

                   myInt: Integer;

               begin

                   JobTaskFilters := "Job Task".GetFilters;

                   Rec_JobTask.Reset();                                      

                   Rec_JobTask.SetRange("Job No.", Job."No.");

                   if Rec_JobTask.FindSet then begin

                       repeat

                           TestAudio2 := "Audio Minutes2";          -----Audio Minutes2 is a duration type field

                           Days_ms := TestAudio2 / 8640000;

                           Hours_ms := TestAudio2 / 3600000;

                           Minutes_ms := TestAudio2 / 60000;

                           Seconds_ms := TestAudio2 / 1000;

                       until Rec_JobTask.Next = 0;

                   end;

  • Suggested answer
    ArturV Profile Picture
    225 on at

    Compare an example of the format call i sent you:

    FORMAT(%1:%2:%3:%4,Days * 24 + Hours,Minutes,Seconds);

    And yours:

    FORMAT(Days_ms * 24 + Hours_ms, Minutes_ms, Seconds_ms)

    Plus your code is incorrect because if you have no value in the "Audio Minutes 2" field of the last JobTask then the final value will be zero. You need to do it like this:

    Day_ms +=

    Not like you did:

    Day_ms :=

  • Dynamics 365 Business Central Profile Picture
    700 on at

    system is not accepting FORMAT(%1:%2:%3:%4,Days * 24 + Hours,Minutes,Seconds);.....it throws error as FORMAT does not take 4 arguments.

  • ArturV Profile Picture
    225 on at

    The first one is string:

    FORMAT('%1:%2:%3:%4',Days * 24 + Hours,Minutes,Seconds);

  • Dynamics 365 Business Central Profile Picture
    700 on at

    pastedimage1590754897053v1.png

    Tried the same !

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 728 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 545 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 328 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans