How to get Time Diff?

HI All,

i am not able to get difference between Start Time & End Time both (Time Datatype) in Nav 2013 Report

New Time= “End Time”- “Start Time”;

i have taken “New Time” also Time (Data type) in Global varible

i am getting below error


Microsoft Dynamics NAV Development Environment


Type conversion is not possible because 1 of the operators contains an invalid type.

Time := Integer


OK


please help me

Time difference will be in duration (Integer datatype) and result will be in milliseconds.

Thanks Mohan

but how to convert milliseconds into hh:mm:ss

This one has worked for me in the past

// Sample for time difference calculation and output format.

StartTime := TIME;

WITH GLEntry DO BEGIN

Window.UPDATE(1, DATABASE::“G/L Entry”);

Window.UPDATE(2, TABLENAME);

CounterTotal := COUNT;

Counter := 1;

REPEAT

Counter += 1;

Window.UPDATE(3, ROUND(Counter / CounterTotal * 10000,1));

UNTIL NEXT = 0;

END;

EndTime := TIME;

ElapsedTime := 000000T + (EndTime - StartTime);

MESSAGE(‘Start: %1\End: %2\Net: %3’,

FORMAT(StartTime, 0, ‘<Hours24,2>:<Minutes,2>:<Seconds,2>’),

FORMAT(EndTime, 0, ‘<Hours24,2>:<Minutes,2>:<Seconds,2>’),

FORMAT(ElapsedTime, 0, ‘<Hours24,2>:<Minutes,2>:<Seconds,2>’));

Hope it helps you with your project.

Hi Mohan,

if i take Duration with integer datatype am getting one more error

Microsoft Dynamics NAV


The date is not valid.


OK


Hi,

Declare your Duration variable as Time, not Integer. Then use the following assignment statement instead of the one you’re using now. I clipped it from the code segment above …

ElapsedTime := 000000T + (EndTime - StartTime);