In a report I have to calculate the sum of differences between the duration of two elapsed times...
Example:
Time_1 From: 09:00 Time_1 To: 10:00 = elapsed: 01:00:00
Time_2 From: 13:00 Time_2 To: 14:00 = elapsed: 01:00:00
____________________
Sum: 02:00:00
How can I have the Sum? When I try it gives me #Error ...
Thanks!
0
Answers
I can be obvious, but what if to calculate this difference in NAV code and then send calculated value to the report?
It always gives me an error....
Could you attach a screenshot of error message?
simply "#Error" in the report field
in code I get type conversion error even if all three variables are Time.
I'm trying ElapsedTime := TimeTo - TimeFrom; ...
Please, attach a screenshot of type conversion error.
You can just multiply it by 1000 to get seconds.
it seems it doesn't work
Why do you think so? What was the value os milliseconds and what you get multiplying by 1000?
It can be assigned to/from an integer, or BigInteger vars. If you need a number of seconds you need to divide the duration by 1000, not to multiply it by 1000.
Try this: Pass both ElapsedTimeSecsondsInt and ElapsedTimeDurationTxt vars in your data item, then use the text version to display the individual lines duration and ElapsedTimeSecsondsInt to add up the number of seconds.
The ElapsedTimeDuration var is of Duration type, and is used in the example to get proper formatting.
Using of BigInteger in ElapsedTimeMilisecondsBigInt in this case is non-essential as you are only dealing with Time variables, but it is good to get using it as your general habit when dealing with duration, as when you start comparing/formatting datetimes the duration can go out of allowed integer values range easily.
Dynamics NAV, MS SQL Server, Wherescape RED;
PRINCE2 Practitioner - License GR657010572SG
GDPR Certified Data Protection Officer - PECB License DPCDPO1025070-2018-03