Not show days in a report (duration or decimal type)

kssonksson Member Posts: 6
Hi everybody in my first post :)

I have searched about duration topics but I haven't been able to find a solution for this problem.
I have a report in whose final footer I show my duration variable "TotalDuration", whose code I have set TotalDuration := TotalDuration + "To-do".Duration;
Then it shows the result like (e.g.) 1 day 5 hours 40 minutes, but I want it to be displayed as 29 hours 40 minutes.
Also, I don't mind creating other decimal-type variable if it would be easier (in this e.g., 29:40)

Any idea? Thanks in advance!

Answers

  • kinekine Member Posts: 12,562
    You will need to parse the value yourselfs. The duration is in milliseconds, you can easily calculate needed values to display the text as you wish.
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kssonksson Member Posts: 6
    Yes, but where? in the code or table To-do or in my report? It must be easy, but I'm new at Navision... And then what should I write? Something similar to that?: viewtopic.php?t=15655

    Thanks!!
  • kinekine Member Posts: 12,562
    No, that will not work for duration > 24 hours.

    Best will be only on your report, it means only where you really need it...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kssonksson Member Posts: 6
    I tried by creating a new decimal variable instead the duration variable to be able to use the ROUND function, but I don't know how to write to not showing the days... Or shouldn't I use this function?

    Any idea?? Thanks
  • kssonksson Member Posts: 6
    another type of variable I could use would be "time", I wouldn't mine...
    but perhaps the easiest solution would be in duration type, could anyone tell me how can I get my total duration only in hours, I mean, 50 hours 10 minutes instead of 2 days 2 hours 10 minutes, please? probably it's easy...but i'm new at programming... :roll: thanks in advance
  • kinekine Member Posts: 12,562
    As I wrote, it is just mathematical problem. If the Duration is in milliseconds, you can create the string yourself. There is no way around, because e.g. time variable is limited to hours etc.

    MyDuration mod 1000 = milliseconds
    MyDuration div 1000 = "rest in seconds"
    "Rest in seconds" mod 60 = seconds
    "Rest in seconds" div 60 = "Rest in minutes"
    "Rest in minutes" mod 60 = minutes
    "Rest in minutes" div 60 = "Rest in hours"
    etc...

    After that you can create the string...
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
  • kssonksson Member Posts: 6
    OK thank you. Problem solved!

    Milisec := TotalDuration MOD 1000;
    RestSec := TotalDuration DIV 1000;
    Sec:= RestSec MOD 60;
    RestMin := RestSec DIV 60;
    Min := RestMin MOD 60;
    RestHour := RestMin DIV 60;
    DurationString := FORMAT(RestHour) +' hours '+ FORMAT(Min) +' minutes';
Sign In or Register to comment.