Distance calculation

DamjanDamjan 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
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

Best Answer

Answers

  • DamjanDamjan Member Posts: 94
    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 Damjan
Sign In or Register to comment.