문제

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.

다른 팁

I don't believe the first test of hoursWorked=null is correct. I think you need @IsNull(hoursWorked). That said I would think the result would still be false and the formula would continue.

It might be worthwhile to see just what output produces without the @TextToTime.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top