Calculate the date and time of delivery

Hi Everybody,

I want to Calculate the date and time of delivery on Sales Order.

My data is available on the Order as follows:

  • field Created Date Time Order Type: DateTime

  • field Distance on table Ship-to Address

  • Input value speed. Here I can calculate the hours of transportation (Distance/Speed)

Example :

  • Created Date Time Order = “08/07/2018 10:17:00 AM”

  • Distance: 1200 km

  • Speed : 40 km/h

=> Total shipping hours: 30 hours and will go to the distributor’s warehouse at 08/08/2018 4:17 PM

Please help me with a solution and related calculation functions.

Thanks so much.

You can just add the number of milliseconds to your original datetime field and get the arrival time.

IF (“Created Date Time Order” > 0DT) AND (Speed > 0) AND (Distance > 0) THEN
“Arrival Time” := “Created Date Time Order” + Distance / Speed * 3600 * 1000;

3600 = Number of Seconds per Hour
1000 = Number of Milliseconds per Second

Thanks Thomas,

After I add the code and run the report at X speed, I get an error message.

Microsoft Dynamics NAV

Overflow under conversion of Microsoft.Dynamics.Nav.Runtime.Decimal18 value 7440000,00000000001 to System.Int64.


Please round your Milliseconds to complete numbers first.

“Arrival Time” := “Created Date Time Order” + ROUND(Distance / Speed * 3600,1) * 1000;

Thanks Thomas. It’s work