Scenario:
In multi-plant manufacturing or supply chain environments, accurately measuring working days is essential for planning, forecasting, and performance tracking. A common oversight is failing to account for plant-specific holidays, which can lead to operational misalignment, missed delivery deadlines, and inaccurate reports. Hence, non-working days—Sundays and local holidays—must be excluded from calculations to reflect the true timeline between an Order Date and Dispatch Date.
Requirement:
The objective is to calculate working days between the Order Date and Dispatch Date, while excluding:
- All Sundays (standard weekly off)
- Plant-specific holidays (maintained in the Holiday Master)
This approach ensures an accurate reflection of operational timelines for any given order period.
About the Use Case:
This logic is applied across the following datasets:
- Units Data: Includes Order Date, Dispatch Date, and Plant Code.
ID | Order Date | Dispatch Date | Sales | Plant Code |
1 | 01-06-2024 | 03-06-2024 | 7221 | 1501 |
2 | 03-06-2024 | 04-06-2024 | 4531 | 1501 |
3 | 04-06-2024 | 10-06-2024 | 5557 | 1501 |
4 | 05-06-2024 | 08-06-2024 | 1600 | 1501 |
5 | 10-06-2024 | 13-06-2024 | 3117 | 1502 |
6 | 11-06-2024 | 15-06-2024 | 3500 | 1502 |
7 | 12-06-2024 | 14-06-2024 | 3211 | 1502 |
8 | 14-06-2024 | 24-06-2024 | 3515 | 1502 |
9 | 14-06-2024 | 17-06-2024 | 4551 | 1502 |
10 | 15-06-2024 | 17-06-2024 | 3456 | 1502 |
- Holiday Master: Maintains holiday entries specific to each plant.
We have Holiday Master which consists of Holiday Name, Date with their respective Plant Code.
Holiday Name | Date | Plant Code |
Public Holiday | 06-06-2024 | 1501 |
Local Festival Holiday | 07-06-2024 | 1502 |
Public Holiday | 13-06-2024 | 1502 |
- Weekend Master: Lists Sundays (or any additional weekend rules if extended in future).
(Note: Only Sundays are considered as weekends)
Holiday Name | Date |
Sunday | 02-06-24 |
Sunday | 09-06-24 |
Sunday | 16-06-24 |
Sunday | 23-06-24 |
Sunday | 30-06-24 |
Below is the expected the output:
ID | Order Date | Dispatch Date | Plant Code | Sales | Working Days |
1 | 01-Jun-24 | 03-Jun-24 | 1501 | 7221 | 2 |
2 | 03-Jun-24 | 04-Jun-24 | 1501 | 4531 | 2 |
3 | 04-Jun-24 | 10-Jun-24 | 1501 | 5557 | 5 |
4 | 05-Jun-24 | 08-Jun-24 | 1501 | 1600 | 4 |
5 | 10-Jun-24 | 13-Jun-24 | 1502 | 3117 | 3 |
6 | 11-Jun-24 | 15-Jun-24 | 1502 | 3500 | 4 |
7 | 12-Jun-24 | 14-Jun-24 | 1502 | 3211 | 2 |
8 | 14-Jun-24 | 24-Jun-24 | 1502 | 3515 | 9 |
9 | 14-Jun-24 | 17-Jun-24 | 1502 | 4551 | 3 |
10 | 15-Jun-24 | 17-Jun-24 | 1502 | 3456 | 2 |
This use case ensures that business timelines accurately reflect actual working availability, thereby enhancing SLA tracking, improving forecasting accuracy, and driving greater operational transparency. As a result, it significantly contributes to better process accountability and informed decision-making.
Our Goal is Straightforward
Calculate the number of working days (normal business days) between the Order Date and Dispatch Date, excluding Sundays and plant-specific holidays.
Logical Steps to Calculate Working Days:
Step 1: Gather and Combine Data
- Merge the order data with holiday and weekend data.
- Ensure each order is cross-checked against plant-specific holidays and all Sundays.
Step 2: Calculate Non-Working Days
- For each record, count the number of holidays and Sundays between the Order Date and Dispatch Date.
Step 3: Calculate Actual Working Days
- Subtract the non-working days (Sundays and holidays) from the total number of days between Order Date and Dispatch Date.
Formula:
Working Days = (Dispatch Date - Order Date + 1) - Holiday Count - Sunday Count
Both start and end dates are included.
Steps to create the example source report in Smarten.
Step 1: Create a data source for Holiday Master, Sunday Master and Sales data from the CSV/Excel file and then create the datasets from the created source.
For this instance, we will use an Excel file as the source.
Datasource for Holiday Master
Datasource for Sunday Master
Datasource for Sales Data
Below is the resultant datasets
Holiday Master Dataset
Sunday Master Dataset
Sales Dataset
Step 2: Now add the Holiday Master and Sunday Master datasets to the main Sales dataset.
Step 3: Now join the Holiday Master with the Sales dataset.
The SQL query provided performs a selection of specific sales data from a sales table and associates it with a holiday calendar table to count the number of holidays that fall within the period between the Order Date and the Invoice Date for each record.
The below is the required SQL Query:
Now join the Sunday Master with the Sales dataset
The SQL query provided is designed to calculate the number of Sundays that fall within a given sales transaction period, along with other relevant sales information. Here's a detailed breakdown of the query:
The below is the required SQL Query:

Step 4: Now calculate the Working Days
Working Days:
dateDiff (“d", Dispatch_Date, Order_Date) - HolidayCount - SundayCount + 1
Conclusion:
This method provides an accurate working day count by removing non-operational days tied to both general weekends and plant-specific holidays. The result is a more truthful reflection of actual business timelines, ensuring better scheduling, resource allocation, and SLA tracking.
Was this article helpful?
That’s Great!
Thank you for your feedback
Sorry! We couldn't be helpful
Thank you for your feedback
Feedback sent
We appreciate your effort and will try to fix the article