Cognito-forms – Subtracting hours

cognito-forms

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'"

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.

enter image description here