Good Morning, I have been able to make this work adapting code in another solution from 2009 but the only way was using military time. If anyone has a way to let the user enter either 12 or 24-hour time in the Time In and Out fields and still get the calculations feel free to let me know. The form is located here (https://drive.google.com/drive/folders/1l8pcqcTVBdvNlEkiK5AdMuTHnsMk9I1J?usp=sharing) if this helps anyone and the script I used is below:
var timeStamp
var timeOut
var timeIn
var Cat
var timep1
var timep2
var timep3
var timep4
var StartInterval
if (HasValue($.parent.timeClockOut) and HasValue($.parent.timeClockIn)) then
timeStamp = $.parent.timeClockOut.formattedValue
Cat = At(timeStamp,":")
timep1 = Left(timeStamp, Cat-1)
timep2 = Right(timeStamp, len(timeStamp)- Cat)
timeStamp = $.parent.timeClockIn.formattedValue
Cat = At(timeStamp,":")
timep3 = Left(timeStamp, Cat-1)
timep4 = Right(timeStamp, len(timeStamp)- Cat)
if (Ceil(timep1) < Ceil(timep3)) then
timep1 = timep1+12
if (timep1 <= 9) then
timep1 = concat("0", timep1)
xfa.host.messageBox(timep1)
endif
endif
if (Ceil(timep2) >= 0 and Ceil(timep2) <= 7) then
timeOut = concat(timep1, ":", "00")
endif
if (Ceil(timep2) >= 8 and Ceil(timep2) <= 22) then
timeOut = concat(timep1, ":", "15")
endif
if (Ceil(timep2) >= 23 and Ceil(timep2) <= 37) then
timeOut = concat(timep1, ":", "30")
endif
if (Ceil(timep2) >= 38 and Ceil(timep2) <= 52) then
timeOut = concat(timep1, ":", "45")
endif
if (Ceil(timep2) >= 53 and Ceil(timep2) <= 59) then
timep1 = timep1+1
if (timep1 <= 9) then
timep1 = concat("0", timep1)
endif
timeOut = concat(timep1, ":", "00")
endif
if (Ceil(timep4) >= 0 and Ceil(timep4) <= 7) then
timeIn = concat(timep3, ":", "00")
endif
if (Ceil(timep4) >= 8 and Ceil(timep4) <= 22) then
timeIn = concat(timep3, ":", "15")
endif
if (Ceil(timep4) >= 23 and Ceil(timep4) <= 37) then
timeIn = concat(timep3, ":", "30")
endif
if (Ceil(timep4) >= 38 and Ceil(timep4) <= 52) then
timeIn = concat(timep3, ":", "45")
endif
if (Ceil(timep4) >= 53 and Ceil(timep4) <= 59) then
timep3 = timep3+1
if (timep3 <= 9) then
timep3 = concat("0", timep3)
endif
timeIn = concat(timep3, ":", "00")
endif
StartInterval = Time2Num(timeOut, "HH:MM") - Time2Num(timeIn, "HH:MM")
else
StartInterval = 0
endif
var LunchInterval
if (HasValue($.parent.lunchTimeClockIn) and HasValue($.parent.lunchTimeClockOut)) then
timeStamp = $.parent.lunchTimeClockIn.formattedValue
Cat = At(timeStamp,":")
timep1 = Left(timeStamp, Cat-1)
timep2 = Right(timeStamp, len(timeStamp)- Cat)
timeStamp = $.parent.lunchTimeClockOut.formattedValue
Cat = At(timeStamp,":")
timep3 = Left(timeStamp, Cat-1)
timep4 = Right(timeStamp, len(timeStamp)- Cat)
if (Ceil(timep1) < Ceil(timep3)) then
timep1 = timep1+12
endif
if (Ceil(timep2) >= 0 and Ceil(timep2) <= 7) then
timeOut = concat(timep1, ":", "00")
endif
if (Ceil(timep2) >= 8 and Ceil(timep2) <= 22) then
timeOut = concat(timep1, ":", "15")
endif
if (Ceil(timep2) >= 23 and Ceil(timep2) <= 37) then
timeOut = concat(timep1, ":", "30")
endif
if (Ceil(timep2) >= 38 and Ceil(timep2) <= 52) then
timeOut = concat(timep1, ":", "45")
endif
if (Ceil(timep2) >= 53 and Ceil(timep2) <= 59) then
timep1 = timep1+1
if (timep1 <= 9) then
timep1 = concat("0", timep1)
// xfa.host.messageBox(timep1)
endif
timeOut = concat(timep1, ":", "00")
endif
if (Ceil(timep4) >= 0 and Ceil(timep4) <= 7) then
timeIn = concat(timep3, ":", "00")
endif
if (Ceil(timep4) >= 8 and Ceil(timep4) <= 22) then
timeIn = concat(timep3, ":", "15")
endif
if (Ceil(timep4) >= 23 and Ceil(timep4) <= 37) then
timeIn = concat(timep3, ":", "30")
endif
if (Ceil(timep4) >= 38 and Ceil(timep4) <= 52) then
timeIn = concat(timep3, ":", "45")
endif
if (Ceil(timep4) >= 53 and Ceil(timep4) <= 59) then
timep3 = timep3+1
if (timep3 <= 9) then
timep3 = concat("0", timep3)
endif
timeIn = concat(timep3, ":", "00")
endif
LunchInterval = Time2Num(timeOut, "HH:MM") - Time2Num(timeIn, "HH:MM")
else
LunchInterval = 0
endif
// compute total time in hours from the millisecond value
sum((StartInterval - LunchInterval) / 3600000)