Tuesday, March 19, 2013

Infopath calculate time difference between two inputs

Need to get the number of hours between two timeinputs in infopath. This will always be on the same day.
60 * (substring(laterTime, 12, 2) - substring(earlierTime, 12, 2)) + (substring(laterTime, 15, 2) - substring(earlierTime, 15, 2)) + (substring(laterTime, 18, 2) - substring(earlierTime, 18, 2)) div 60
When pasting this to a field in infopath, we first need to remap latertime and earliertime to relevant fields in our own form. When trying to verify the formula it throws an error stating a missing ,
Upon closer examination of the xpath values we notice than an extra . is in place where the , should be .
When the dots are are replaced with commas the code works as it should.

No comments: