Subtracting time

poloniouspolonious Member Posts: 64
Hi guys, i have a start time and end time and want to calculate the time taken. Can anyone help me with the code please. Thanks.

Comments

  • kolaboykolaboy Member Posts: 446
    HI Plonius,
    You can use this:
    IF "end time " <>0T THEN
    "start time" :=("end time " - "start time")/3600000;
    

    Hope this will help.
    Put the code in OnAfterGetRecord(end time and start time)
  • babbab Member Posts: 65
    Hi polonius,
    if you substract two field (variable) of type time, you will get an integer, which contains the time between your two field (variable) in miliseconds.
    StartingTime := 1400T;
    EndingTime := 1401T;
    MESSAGE(FORMAT(EndingTime-StartingTime));
    
    The Result will be 60000.
    You can also use a variable with type Duration for the result.
  • poloniouspolonious Member Posts: 64
    Thanks guys, much appreciated.
  • kinekine Member Posts: 12,562
    Or you can check on-line help for datatype DURATION. There are examples how to use that type... :wink:
    Kamil Sacek
    MVP - Dynamics NAV
    My BLOG
    NAVERTICA a.s.
Sign In or Register to comment.