Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

How to calculate hours from clock-in and out?

Avatar

Former Community Member

i am now doing an overtime claim form for my company, and i want to know how to calculate hours from the clock in and clock out field. i had done this in a table layout where the columns are for clock in (in 24-hours format), clock out(in 24-hours format) and counted hours.

CLOCK INCLOCK OUTCOUNTED HOURS
4 Replies

Avatar

Former Community Member

How about this? You enter the time in 24-hour format, the time gets converted using a time pattern and the counted hours are calculated.

Untitled.pngUntitled1.png

// form1.page1.subform1.table.row[0].countedHours::calculate - (FormCalc, client)

if (HasValue(clockedIn) and HasValue(clockedOut)) then

  var in_ = Time2Num(clockedIn.formattedValue, "h:MM A")

  var out_ = Time2Num(clockedOut.formattedValue, "h:MM A")

  if (in_ >= out_) then

    xfa.host.messageBox("The clocked in time cannot be greater than or equal to the clocked out time.")

    $.rawValue = null

  else

    var diff =  out_ - in_

    $.rawValue = diff/3600000

  endif

else

  $.rawValue = null

endif

Steve

Avatar

Level 2

Can you get this to work for the nightshift?

example Clock in at 9pm and clock out at 5am..