Difference between duration time
sharon95
Member Posts: 183
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!
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 tried with FormatDateTime(Sum(Fields!TimeToG.Value - Fields!TimeFromG.Value),DateFormat.LongTime) but it doesn't work...0
-
Type conversion is not possible because 1 of the operators contains an invalid type. Time := Integer0
-
if I write Sum(Fields!TimeToG.Value - Fields!TimeFromG.Value) in the report I get the milliseconds.... any help?0
-
The Duration type is stored/calculated as a number of milliseconds.
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:ElapsedTimeMilisecondsBigInt := TimeTo - TimeFrom; ElapsedTimeSecsondsInt := ROUND( ElapsedTimeMilisecondsBigInt/ 1000.0, 1); ElapsedTimeDuration := ElapsedTimeSecsondsInt * 1000; //back to miliseconds ElapsedTimeDurationTxt := FORMAT(ElapsedTimeDuration);
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.Slawek Guzek - www.yitron.co.uk
Business Central, MS SQL Server, Wherescape RED;0
Categories
- All Categories
- 75 General
- 75 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 611 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 253 Dynamics CRM
- 103 Dynamics GP
- 6 Dynamics SL
- 1.5K Other
- 991 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 28 Design Patterns (General & Best Practices)
- Architectural Patterns
- 9 Design Patterns
- 4 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1K General Chat
- 1.6K Website
- 77 Testing
- 1.2K Download section
- 23 How Tos section
- 249 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions
