Sunday, October 20, 2013

How to convert Duration to Integer Dynamics NAV

Hi All

Below example will convert the duration variable to integer, Normally in  Dynamics NAV duration data type will display the data as  like  "5 Days 7 Hours 35 Minutes 12 seconds". Even some times it will include Milli seconds too so how to convert this into integer to calculate the exact hours spent

Name               DataType    Subtype    Length
ProcessStart     DateTime       
ProcessEnd      DateTime
TimeDuration  BigInteger
TotalHours       Integer        


ProcessStart := CREATEDATETIME(010109D,072005T);
ProcessEnd := CREATEDATETIME(300109D,103000T);
TimeDuration := ProcessEnd - ProcessStart;
TotalHours := TimeDuration/3600;
Message('%1',TotalHours);

above code will give the exact time (hours) spent in a process.

1 comment:

  1. Hi, I need Decimal to Conversion in Minutes,
    Ex = (194 is a decimal and in need 3 hrs and 14 min)
    OR 194 is a decimal in minutes

    ReplyDelete