I have two editable time/date fields, TimeIn
and TimeOut
, and one computed for display field hoursWorked
, what it does is get the difference between TimeIn
and TimeOut
and display it in hours:minutes, e.g (02:30 hrs). I decided to have another editable time/date fieldTimeIn_1
and TimeOut_1
field and computed for display field hoursWorked
and another computed for display field totalHours
, which displays the total/sum of hours of hoursWorked
and hoursWorked_1
. I tried this code:
thours:=@If(hoursWorked=null | hoursWorked_1=null; @Return(""); "" );
seconds := hoursWorked+hoursWorked_1;
hours := @Integer(seconds/3600);
minutes := @Integer(@Modulo(seconds;3600)/60);
output := @Right("00" + @Text(hours); 2) + ":" + @Right("00" + @Text(minutes); 2);
@TextToTime(output)
but nothing happens. Can you help me?
I assume that you calculated your fields hoursWorked
and hoursWorked_1
the same way like in this formula shown. If that is the case, the fields hoursWorked
and hoursWorked_1
are from type "Date/Time" in document no matter how you define the fields in form.
That's why your formula should look like this:
thours:=@If(@IsNull(hoursWorked) | @IsNull(hoursWorked_1); @Return(""); "" );
nullTime := @ToTime("00:00");
seconds := (@ToTime(hoursWorked) - nullTime)+ (@ToTime(hoursWorked_1) - nullTime);
hours := @Integer(seconds/3600);
minutes := @Integer(@Modulo(seconds;3600)/60);
output := @Right("00" + @Text(hours); 2) + ":" + @Right("00" + @Text(minutes); 2);
@TextToTime(output)
Only first three lines are different to your formula.