You're almost there! Please answer a few more questions for access to the Applications content. Complete registration
Interested in joining? Complete your registration by providing Areas of Interest here. Register
Get Started with Redwood for Oracle Cloud HCM   Begin Now
To ensure that questions get required attention from community members and are NOT left unanswered, it’s important for the author to indicate (by selecting “Yes” or “No” when prompted) whether the question was answered. (newly added) Please note that it is also important to respond to EACH comment your question receives. Your Yes or No response ensures an accurate status for your question.

For more information, please refer to this announcement explaining best practices for getting answers to questions.

Calculating the Number of Business Days

edited Jun 15, 2018 9:51PM in Reporting and Analytics for HCM 1 comment

Summary

Count the number of Business Days between 2 dates

Content

I constantly get requests to provide reporting based on Business Days rather than Calendar Days. Calculating the difference between 2 Calendar dates is easy: 

 

This example shows 2 days:

Created Date

Closed Date

 

TIMESTAMPDIFF(SQL_TSI_DAY, "Time"."Created Date", "Time"."Closed Date")

No big deal!

 But what if your challenging user asks to exclude weekends (ie Business Days), not so easy. Here’s the magical code that will make you a hero:

 -TIMESTAMPDIFF(SQL_TSI_DAY,TIMESTAMPADD(SQL_TSI_DAY,-(DAYOFWEEK("Time"."Closed Date")-1),"Time"."Closed Date"), TIMESTAMPADD(SQL_TSI_DAY,-(DAYOFWEEK(TIMESTAMPADD(SQL_TSI_DAY,6,"Time"."Created Date"))-1),TIMESTAMPADD(SQL_TSI_DAY,6,"Time"."Created Date")))/7*5+ MOD(7-DAYOFWEEK("Time"."Created Date"),6)+CASE WHEN DAYOFWEEK("Time"."Closed Date")-2>5 THEN 5 ELSE DAYOFWEEK("Time"."Closed Date")-2 END

Tagged:

Howdy, Stranger!

Log In

To view full details, sign in.

Register

Don't have an account? Click here to get started!