Forum Discussion

manoharvankired's avatar
manoharvankired
Qrew Trainee
2 years ago

How to calculate the number of hours between four date/time fields, excluding weekends

let (
  start = ToDate([Start Date]),
  end = ToDate([End Date]),
  onHoldStart = ToDate([On Hold Start Date]),
  onHoldEnd = ToDate([On Hold Stop Date]),
  duration = If(
    Not(IsNull(start)) and Not(IsNull(end)) and Not(IsNull(onHoldStart)) and Not(IsNull(onHoldEnd)),
    WeekdaySub(end, start) - WeekdaySub(onHoldEnd, onHoldStart),
    0
  ),
  durationInDays = ToDays(duration),
  durationInHours = ToInt(Duration(0, 0, durationInDays).ToHours()),
  durationInMinutes = ToInt(Duration(0, 0, durationInDays).ToMinutes())
);

durationInHours & " hours " & durationInMinutes & " minutes"

I'm getting error please see attached screenshot 

Note: output field type is duration 



------------------------------
manohar vankireddy
------------------------------

2 Replies

  • You're using javascript syntax which isn't allowed.   



    ------------------------------
    Jeff Peterson
    ------------------------------
    • manoharvankired's avatar
      manoharvankired
      Qrew Trainee

      Hi Jeff,

      Could you please help me on this ?

      Thanks

      Manohar



      ------------------------------
      manohar vankireddy
      ------------------------------