I have 3 fields;
Time Field 1 called StartTime
Time Field 2 called EndTime
I'd like to calculate the difference between these 2 fields into the another field called TotalTime in hours.
EndTime cannot be greater or equal to StartTime. In this case a message should warn the user.
Could you help me with that please?
Views
Replies
Total Likes
You would use the functions Time2Num and Num2GMTime to do this. In the calculate event of the total time field you would put something like (in formcalc):
var startT = StartTime.formattedValue
var endT = EndTime.formattedValue
var differenceT = Time2Num(endT, "HH:MM:SS") - Time2Num(startT, "HH:MM:SS")
$ = Num2GMTime(differenceT, "HH:MM:SS")
- the "HH:MM:SS" bit should be whatever time pattern you have used.
Views
Replies
Total Likes
Thank you it's calculating but not as I was expecting. Basically total hours needs to be multiplied with a "$" rate in the total text field but your script only puts a time again so result needs to be a number instead of a time!. Also EndTime cannot be greater or equal to StartTime. In this case a message should warn the user. Is it possible to achieve this?
Kind regards
Views
Replies
Total Likes
The result should be the number of hours/minutes difference - but yes with that pattern it shows as a time.
To make sure the end time is after the start time use Time2Num for both and then make sure the number of the end time is larger than the number of the start time.
Views
Replies
Total Likes
I am not sure what I am doing wrong - but using this script I get an answer of zero?
startT = StartTime.formattedValue
endT = EndTime.formattedValue
differenceT = Time2Num(endT, "HH:MM:SS") - Time2Num(startT, "HH:MM:SS")
= Num2GMTime(differenceT, "HH:MM:SS")
For the answer field I use a numericfield
Can you help please?
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies