How to Convert Duration data type into hours

Hi All

how to convert 30 days 21 hours 55 minutes 50 seconds into hours in NAV 2013 Report

Hi

Duration data type is normally difference between two datetime data type you can convert to date and get the difference of start and end time for example, but DT2Date will omit the time part and give you the integer output

ProcessStart := CREATEDATETIME(010109D,072005T);
ProcessEnd := CREATEDATETIME(300109D,103000T);
StartDate:= DT2DATE(ProcessStart);
EndDate := DT2DATE(ProcessEnd);
MESSAGE(’%1’,(EndDate-StartDate));

Marshal, this code gives the number of days - not the number of hours as requested.

A duration field is really just a special representation of a BigInteger field, which when formatted displays in the “x days y hours…” format. If you look closer at the field the you’ll see that it really contains the duration in Milli-seconds.

Knowing this then it’s very easy to calculate the number of hours:

Hours := Duration/3600;

This will give you the hours with decimals, if you want it as a “clean” number, then you can just use the normal ROUND function.

Hi Erick,

You are correct as in my previous post also i mentioned that it will omit the time part and give the date difference between start and end , so we can just multiply the difference by 24 but it will not be the exact time duration.As you suggested i tried to find the hours of the duration variable, its working .

Thanks

Jerome Marshal