Skip to main content
Question

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

  • March 10, 2023
  • 0 replies
  • 61 views

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
------------------------------
This topic has been closed for replies.

SSNJeffP
Forum|alt.badge.img+11
  • Registered
  • March 11, 2023

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



------------------------------
Jeff Peterson
------------------------------