I have three editable date/time fields which the first two is (field1 and field2), style: Calendar/time control. Both of them are showing the time: hour and minutes, eg: 15:51.
The third field also (editable) which I want to show the difference between field1 and field2.
Eg: If field1 is 14:41 and field2 is 14:30, then field3 = 00:11. I've tried field1-field2 but isn't working. The form has automatic refresh fields property. Thanks!
Your third field needs to be computed, not editable.
If it HAS to be editable for some reason, and you want it to update when the other two fields are changed, do this:
Create a new field and make it computed-for-display and hidden. Give it a formula like this
@If(field1=null | field2=null; @Return(""); "");
seconds := field1-field2;
hours := @Integer(seconds/3600);
minutes := @Modulo(@Integer(seconds/60); 60);
output := @Right("00" + @Text(hours); 2) + ":" + @Right("00" + @Text(minutes); 2);
@setfield("field3"; output);
@Command([ViewRefreshFields]);
""
Phil