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
Thanks Damjan
This is resolved.
Field: “Travel Time”
Data type changed from Time to Duration
"Travel Time" :=ROUND("Travel Distance"/70,0.1)*3600000;
70 represents 70 km in an hour
If user inserts in field: Travel distance 70, the value on field: “Travel Time” is calculated to 1 hour.
If user inserts in field: Travel distance 140, the value on field: “Travel Time” is calculated to 2 hours.
If user inserts in field: Travel distance 210, the value on field: “Travel Time” is calculated to 3 hours.
If user inserts in field: Travel distance 35, the value on field: “Travel Time” is calculated to 30 minutes.
If user inserts in field: Travel distance 510, the value on field: “Travel Time” is calculated to 7 hours 18 minutes.
Thank you
BR Damjan