Distance calculation

Damjan
Member Posts: 94
Hi,
I have created a function to call Google Maps with address X to address Z, distance is taken from Google Maps and inserted in field: "Travel Distance".
Field: "Travel Distance"
Field Type: Decimal
I would need to calculate travel time based on a value of field: "Travel Distance" and past it in the field: "Travel Time" | Time Data Type
Field: "Travel Time"
Field Type: Time
I would like to add this code on a Page field
Microsoft Dynamics NAV Development Environment
Type conversion is not possible because 1 of the operators contains an invalid type. Time := Decimal
OK
I have created a function to call Google Maps with address X to address Z, distance is taken from Google Maps and inserted in field: "Travel Distance".
Field: "Travel Distance"
Field Type: Decimal
I would need to calculate travel time based on a value of field: "Travel Distance" and past it in the field: "Travel Time" | Time Data Type
Field: "Travel Time"
Field Type: Time
I would like to add this code on a Page field
Rec."Travel Time" := Rec."Travel Distance"/70 * 1000;Compiler reports an error:
Microsoft Dynamics NAV Development Environment
Type conversion is not possible because 1 of the operators contains an invalid type. Time := Decimal
OK
0
Best Answer
-
Rec."Travel Time" := 000000T + ROUND(Rec."Travel Distance"/70 * 1000);
As variant use Duration Field Type for "Travel Time"5
Answers
-
Rec."Travel Time" := 000000T + ROUND(Rec."Travel Distance"/70 * 1000);
As variant use Duration Field Type for "Travel Time"5 -
Hi de_neal,
Works as expected, but I j
I did it like this"Travel Time" :=ROUND("Travel Distance"/70,0.1)*3600000;
It works as expected.
If user types in 70 km, it calculates to 1 hour, if user inserts 210 it calculates to 3 hours, if user inserts 180 it calculates to 2 hour 36 minutes.
Thank you
BR Damjan0
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
- 320 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