Trying to subtract two times. I have a time input box called Start Time and a time input box called End Time. Using a calculated field set to time =(EndTime-StartTime).TotalHours
, I've tried .Hours
as well. No matter how I write the calculation get the error "The expected type of this field is 'DateTime'"
Cognito-forms – Subtracting hours
cognito-forms
Related Topic
- Cognito-forms – Missing fields in Basic/Advanced Editor
- Cognito-forms – Formatting a calculation field number
- Cognito-forms – How to apply coupon code calculation in Cognito Forms
- Cognito Forms – How to Calculate Average
- Cognito-forms – Discount calculation
- Cognito-forms – Decimal.Parse returning NULL value on text calculation displaying IF result
- Cognito-forms – How to calculate the week ending date based on a given date
Best Answer
I am a developer for Cognito Forms, I was able to reproduce this issue in our testing environment when the Calculation Type was set to 'Time'. In the settings for the Calculation Field try setting the Type to 'Number'. You are looking for a number value from the subtraction of the two times. You can continue to use either .Hours or .TotalHours.