• 0

# Calculating Values from Time - MPH and Pace Per Mile

## Question

Hello,

I need to try and figure out how to calculate values from time/distance.  Examples:

1. Calculate miles/hr based on 2 fields: time and distance.  Ex- 1:00:00 (hour) and 20 Miles would be 20mph.

2. Calculate pace per mile based on 2 fields: time and distance.  Ex- 1:00:00 (hour) and 10 Miles would be 6:00/Mile.

Anyone have experience in doing this in Caspio or can offer any help?  I haven't had any luck in making these calculations.  Any help would be greatly appreciated.

Thank you!

## Recommended Posts

• 0

Hello @FishTacos,

Since I am not sure how you store the values, I assume that the time field has the Text(255) data type.

1) In this case, you may try using this formula to calculate miles per hour

[@field:Miles]/(((CAST(Substring([@field:Hours],1,2) as float)*60) + CAST(Substring([@field:Hours],4,2) as float))/60)

Please note, that this formula works if you store the hour as 2-digit number. So, please use leading zero. For example, 01:00:00.

Do not forget to replace the field names with your local names.

2) To calculate pace per mile, please try this formula

((CAST(Substring([@field:Hours],1,2) as float)*60) + CAST(Substring([@field:Hours],4,2) as float))/[@field:Miles]

If you provide more details about the field data types, I can offer a more suitable solution.

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.