Hey People, I have a lil problem here, I am calculating the No. of hours between 2 specific time intervals and adding them together. for eg. Day 1 No. of hours is 5.24 Day 1 No. of hours is 5.24 Day 1 No. of hours is 5.24 ------- Total 15.72 instead of 16.12 Is there any way to get this right. Regards Vishal

In Navision time is a decimal value. The 0.24 value doesn’t mean 24 minutes but 24/100 hour. So, the total of 15.72 is correct.

Hi Peter, I know its correct, but then how do I get around working with this, is there any way, I get hours by deducting 2 time values, for instance a Check in and a Check out time, so the work duration I get is 5.24 hours Vishal

Are the Check in and Check out times in HH:MM or in decimal hours? Are these times stored in a Navision time field?

Hi Peter, The Check in / Check Out is stored in HH:MM:SS format, the deduction gives an a Decimal hours Regards Vishal

Formatting the result might work. I never did that for a time so can’t help you there.

Hi, So then should I believe that there is no work around to this problem…if there I would like to make a request to the Guru’s here, if they could help me out with this problem… Best Regards Vishal

Hi Vishal, I think it’s not so difficult to write a function, which adds one time to another. All you need is to think a little

If you’re working in 3.60 you might consider using the new datatypes DATETIME and DURATION.

Hi Jack, I am aware that 3.6 has this feature, but unfortunately I am working on 3.10. Any other suggestions Vishal

Hi Vishal, I guess these couple of lines should give you some ideas… Variables: CheckIn Time CheckOUt Time DiffHour Decimal DiffMin Decimal DiffTot Decimal

```
CheckIn := 070000T;
CheckOUt := 082400T;
//DiffTot in Minutes
DiffTot := (CheckOUt - CheckIn) / (60 * 1000);
DiffHour := ROUND(DiffTot/60,1);
DiffMin := (DiffTot MOD 60);
//DiffTot in decimal hours
DiffTot := (CheckOUt - CheckIn) / (60 * 60 * 1000);
DiffHour := ROUND(DiffTot,1);
DiffMin := (DiffTot - DiffHour) * 60;
```

You need to make sure from the beginning that the difference between CheckIn and CheckOut get calculated in the correct format… Saludos Nils

Hi Nils, Thanx a ton for the help that you have extended, but if you give value as 080000T to Checkin and 174500tT to Check out the Difftot value u get is 9.75 which is again wrong, as minutes cannot be 75 isnt it you get the DiffMin value as -45 which is correct. But then how would you get 9.45 which is the actual time difference between CheckIn & CheckOut. Iam totalling the values in a report, can definately use a variable to do that but then its not working as its expected to. It aint working… Regards Vishal

Vishal, you need to handle the difference in decimal values, because this way you can perform calculations with the time differences more easily - therefore 9,75 is correct. If later on you want to show these time differences on reports of forms, use the last two lines of the code I posted beforehand to adapt the format to HH:MM or handle these two values in seperate fields, basically convert the 0.75 into 45… Saludos Nils

Hi, there is a more easily way, as I think. As example I get your beforehand example. Day 1 No. of hours is 5.24 Day 1 No. of hours is 5.24 Day 1 No. of hours is 5.24 ------- Total 15.72 This value is in decimal. If you want this in HH:MM, just do this: transform 15.72 back to miliseconds: dec_ms := (15.72 * 60 * 60 * 1000) and finally time := 000000T + dec_ms; Now ‘time’ is: 15:43:12;