0

Need help with very simple for loop

Hey Everybody,

Im a truck driver and a very novice programmer to Ninox. Im trying to setup a database to track my loads and I need help with a very simple code I can't remember from high school to get done

I have a formula to calculate the drive time based on the miles from point A to point B set to 50 mph. ie (miles /50) displays a number. Easy enough!!

I'm trying to add a loop formula that will calculate every 8.5 hours to add 10 hours to the total. Example (drive time = 27.5 hours. I need to add 10 hours to the Total time driving. total = 57.5 hours) 

this is necessary to keep track of how many hours I can drive in a day and not violate federal law. any help would be appreciated! thanks

1 reply

null
    • John_Halls
    • 2 yrs ago
    • Reported - view

    Hi corey

    There's no need for a loop. You need to know how many 8.5's there are in the total time. For the example you gave  27.5/8.5 = 3.24 but you just need the whole number part of this, ie 3. This is given with the floor function. floor(27.5/8.5) = 3. Now multiply this by 10 and add it to your initial number of hours

    27.5 + floor(27.5/8.5)*10 = 57.5

    Regards John