How to get working days between 2 time stamps

Certified Senior Developer

I am calculating time difference between 2 time stamps in   hours: min :sec   format  .

Now my problem is I have to eliminate weekends between 2 time stamps and calculate difference in   hours: min :sec   format  

  Discussion posts and replies are publicly visible

Parents Reply
  • 0
    Certified Senior Developer
    in reply to likhithan

    a!localVariables(
      local!date1: (
        "Your date time 1 here" - todatetime("01/01/1970")
      ) * 24 * 60 * 60,
      local!date2: (
        "Your date time 2 here" - todatetime("01/01/1970")
      ) * 24 * 60 * 60,
      local!getEpochfor1: index(split(local!date1, ":"), 1, null),
      local!getEpochfor2: index(split(local!date2, ":"), 1, null),
      local!difference: local!getEpochfor2 - local!getEpochfor1,
      local!days: rounddown(local!difference / 86400, 0),
      local!hours: rounddown(mod(local!difference / 3600, 24), 0),
      local!minutes: rounddown(mod(local!difference / 60, 60), 0),
      local!sec: rounddown(mod(local!difference, 60), 0),
      concat(
        local!days,
        " Days",
        " ",
        local!hours,
        " Hours",
        " ",
        local!minutes,
        " Mins",
        " ",
        local!sec,
        " Secs"
      )
    )

    Try replacing your date time values in the local!date1 and local!date2. Not sure how accurate it works for all values. But as far as I am getting for different values, it is giving me the expected answer

Children