AndreonnaGarret
7 years agoQrew Assistant Captain
Calculate Weekend Hours in a duration of Date/Time Field
I will try to explain this the best that I can. I am trying to calculate the number of hours between two date/time fields excluding weekends. I have seen quite a bit of chatter, but no solution to the problem.
I've come closest by using the following post as a guideline:
https://community.quickbase.com/quickbase/topics/calculate-duration-excluding-weekends-dependent-fie...
However, I'm running into some trouble. While I can get it to tell me the number of weekend days and subtract that, I need it to tell me weekend hours. The idea here is to gather data on how long it takes to go from submitted to approved. So if I have 72 hours to approve a form that should exclude weekends, because I don't work weekends.
However, the form can be submitted at any time weekends included. So my submission date could be on a weekend. However, the approval date should only be on a weekday. So the duration between the submission and approval dates should exclude weekends.
For example, I have a
submission date/time = 5/12/18 9:06 AM
approval date/time = 5/14/18 8:05 AM
So a simple duration calculation between the two fields would return 46 hours and 59 minutes, the actual time of approval should be 8 hours and 5 minutes when only weekdays are included.
I am using the following formula which would exclude an entire 48 hours in this instance, thus returning a value of -1 hour and 1 minute:
var Duration HoursInclude = Max(Hours(0), [FSR Sent Date]-[Approval 1 and 2 Complete Time]);
var Number HoursExclude = ToDays(ToDate([FSR Sent Date]) - ToDate([Approval 1 and 2 Complete Time])) - WeekdaySub(ToDate([FSR Sent Date]), ToDate([Approval 1 and 2 Complete Time]));
$HoursInclude - Hours($HoursExclude * 24)
Does anyone have any thoughts on how to get this to work the way I need it to?
I've come closest by using the following post as a guideline:
https://community.quickbase.com/quickbase/topics/calculate-duration-excluding-weekends-dependent-fie...
However, I'm running into some trouble. While I can get it to tell me the number of weekend days and subtract that, I need it to tell me weekend hours. The idea here is to gather data on how long it takes to go from submitted to approved. So if I have 72 hours to approve a form that should exclude weekends, because I don't work weekends.
However, the form can be submitted at any time weekends included. So my submission date could be on a weekend. However, the approval date should only be on a weekday. So the duration between the submission and approval dates should exclude weekends.
For example, I have a
submission date/time = 5/12/18 9:06 AM
approval date/time = 5/14/18 8:05 AM
So a simple duration calculation between the two fields would return 46 hours and 59 minutes, the actual time of approval should be 8 hours and 5 minutes when only weekdays are included.
I am using the following formula which would exclude an entire 48 hours in this instance, thus returning a value of -1 hour and 1 minute:
var Duration HoursInclude = Max(Hours(0), [FSR Sent Date]-[Approval 1 and 2 Complete Time]);
var Number HoursExclude = ToDays(ToDate([FSR Sent Date]) - ToDate([Approval 1 and 2 Complete Time])) - WeekdaySub(ToDate([FSR Sent Date]), ToDate([Approval 1 and 2 Complete Time]));
$HoursInclude - Hours($HoursExclude * 24)
Does anyone have any thoughts on how to get this to work the way I need it to?