how to calculate times in c/al ? (opened again)
 
            
                
                    Manuel_A.                
                
                    Member Posts: 22                
            
                        
            
                    How can i calculate times in c/al ?
For example:
sum:=endtime-starttime;
All of them are set as "Time" but i get an convert Error. time:=integer.
regards
Manuel A.
                For example:
sum:=endtime-starttime;
All of them are set as "Time" but i get an convert Error. time:=integer.
regards
Manuel A.
0                
            Comments
- 
            sum is integer - difference between the two times in milisecondsStamen Delikostov
 Navision Solution Developer
 Intelligent Systems Bulgaria0
- 
            no, i declared sum also as time. Its a value in a table i created.0
- 
            What you think is the differnece between two times?Stamen Delikostov
 Navision Solution Developer
 Intelligent Systems Bulgaria0
- 
            Starttime= 08:00
 Endtime = 12:00
 Break = 00:30
 The Difference is:
 sum=Endtime-Startime-Break
 sum=12:00-08:00-00:30
 sum=3:30 (hours)
 thats what i want to create0
- 
            s.delikostov is correct. You should make your field sum into an Integer type.
 As s.delikostov, said Navision calculates the difference between 2 times as milliseconds.
 You can then convert the milliseconds into hours.
 You shouldn't have Break as a time field though. You should make a new field called "Break in Minutes" (or something like that).
 Then work out the difference between Start Time and End Time. Convert that to minutes. Subtract "Break in Minutes", this will return total time taken in minutes. You can then convert that to hours if that is what you need.
 -- EDIT --
 When converting from Seconds to minutes (and to hours) you will need to use a decimal field as you will be incurring decimals.
 Eg: In your example, when you eventually reach your answer it will be 3.5 (hours), therefore you will need a decimal.This isn't a signature, I type this at the bottom of every message0
- 
            ok, i set sum to integer, now it works.
 Which command do i have to use to convert it to hours?0
- 
            sum=12:00-08:00
 sum=14400000
 hours=14400000/3600000=4Stamen Delikostov
 Navision Solution Developer
 Intelligent Systems Bulgaria0
- 
            of course....just have to divide it...  
 thank you0
- 
            its me again....
 how can i subtract the "break" too ? I cant subtract 3 values only 2 like you described.0
- 
            How you calculate break time?
 If it's 12:30-12:00 - this is 0.5 hours
 if you enter 0:30 - this is not correct, better way is to enter it in a decimal - 0,5Stamen Delikostov
 Navision Solution Developer
 Intelligent Systems Bulgaria0
- 
            do not forget new type "Duration" which is in ms but to user shows something as "3 hours 5 minutes"....0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K 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
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 323 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions


