Need help with a FormCalc script for time diffrence in 24 hour format on same day.
My table have repeted rows. User enter date, start time, end time and break time for each row
If he starts work midnight he enter 00:00 and if ending midnight he enter 00:00 (display set to "KK:MM" therefore 00:00 = 24:00)
All work great when entering 00:00 to 23:59
But when entering 00:00 (24:00) in end time the diffrence is -24 hours
What line do I need to add so it will work with 00:00 in the WorkTo?
form1.#subform.Table1.Row1.WorkTotalWorkTotal::calculate - (FormCalc, client)
var startTime = Time2Num(WorkFrom.formattedValue, "HH:MM")
var finishTime = Time2Num(WorkTo.formattedValue, "KK:MM")
if (WorkFrom==null | WorkFrom=="" | WorkTo==null | WorkTo=="")
$=((finishTime) - (startTime)) / 3600000 - WorkBreak
Since 00:00 and 24:00 are the same, you'll have to add another if expression:
if (not WorkFrom.isNull and not WorkTo.isNull) thenvar startTime = Time2Num(WorkFrom.formattedValue, "HH:MM")var finishTime = Time2Num(WorkTo.formattedValue, "KK:MM")if (startTime eq finishTime) then$ = 24else$ = (finishTime - startTime) / 3600000endifelse$ = ""endif
if (not WorkFrom.isNull and not WorkTo.isNull) then
if (startTime eq finishTime) then
$ = 24
$ = (finishTime - startTime) / 3600000
$ = ""
Good day radzmar
Thanks for your reply
If I enter 00:00 to 24:00 the result is 24 hours which is corect
If I enter 01:00 to 24:00 the result is -1 which should be 23 hours (I do understand that is calculate "00:00" - "01:00" = -1)
Where im struggling is - if Work To is 24:00/00:00 then the calculation should be "Work to - Frok From" + 24, but dont know how the convert this to FormCalc script